Skip to main content

Dialog not getting disposed when called from a thread.

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2010-06-15

Hi ,

I am facing an issue in disposing a dialog. i have a method in which i am just creating a non-modal dialog and displaying it. And i am using this as a audio player and once the song gets finished i am just calling dispose on this dialog. Everything is working fine but the issue comes when i try to call this method from a different thread.

When i call this from a different thread then the audioplayer(Dialog) gets popped up and all the controls work, but dialog is not getting disposed and its blocking the entire screen.not able to understand where am i going wrong with this. for this dialog i am having a command called "Cancel" in which i am doing like this:

if (cmd.getId() == MyConstants.SMALLPLAYERBACK) {

if (myAudioPlayer != null) {

myAudioPlayer.close(); // myAudioPlayer is an instance of Player

myAudioPlayer = null;


if (SongDetailsController.lockObject != null) {

synchronized (SongDetailsController.lockObject) {




audioPlayer.dispose(); //audioPlayer is my Dialog's instance

createInfoDialog("Info ", "Hey i have done disposed the small player and now i am showing this", new Command("OK"));


Also tried to dispose the dialog with callserially and callseriallyandwait(), But none of them worked in my case.

Runnable dispose = new Runnable() {

public void run() {

if(audioPlayer != null)





private void disposeAudioPlayer()




But no luck as of now, nothing worked in my case.

so i just want to know can i dispose a dialog from a thread? Or is there anything that i'm missing here? Can anyone please help me.

Thanks in advance


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2003-11-07

LWUIT is not threadsafe by design, you need to only invoke LWUIT on the EDT.

To dispose the dialog just use Display.getInstance().callSerially(new Runnable() {

public void run() {