Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Regular Contributor
Posts: 59
Registered: ‎03-01-2011
My Device: Not Specified
Accepted Solution

Call Dialog.ask in Thread Run method

in thread i want to call Dialog.alert and using following code but its throwing out exception"

Exception occurs java.lang.RuntimeException: pushModalScreen called by a non-event thread"

synchronized (Application.getEventLock())


if(Dialog.ask("Catalog is out of Date. Do You want to continue it?",choices,select,select[0])==1)


        //Perform required Functionality



pls help out me

Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Call Dialog.ask in Thread Run method

I keep saying this, so forgive me for repeating myself but:


synchronized (Application.getEventLock()) {}


should only be used when nothing else will work for you or you are performing a very simple, very quick UI Update. 


A Dialog.ask is not very quick!


In this case you have a number of options, but the most obvious solution is to ask the question before you start the Thread.  So, say your processing is


Thread catUpdateThread = new Thread() {

public void run() {


// Other processing





This should do the same thing and work OK.:


UiApplication.getUiApplication.invokelater(new Runnable() {

public void run() {


if ( result == yes ) {

Thread catUpdateThread = ...;