0

how to kill a thread in blackberry. I am using below code in which i want to kill a thread when dialog popup. On first time login failed it is working properly but on second time login failed it returns RunTimeException.

public void onAuthFailed(String message) {
        //this.invokeAndWait(new NotifyDialog("Please enter correct username and password"));
        UiApplication.getUiApplication().invokeLater(new Runnable(){
            public void run(){
                Dialog.alert("Please enter correct username and password.");
                UiApplication.getUiApplication().pushScreen(loginscreen);
            }
        });
    }
ricky khatri
  • 91
  • 1
  • 11
  • 2
    Terminating a thread in BB is no different from JavaME. So this question is a possible duplicate. Check here: http://stackoverflow.com/q/671049/813951 – Mister Smith Aug 31 '12 at 10:27

1 Answers1

1

Code you posted is not dedicated to kill a thread. It will display a new screen. And I thing you are trying to display a screen object, that is already displayed. I. e loginscreen instance is already displayed. If loginscreen is not displayed, then there's confict (event lock) between new dialog box and screen to be displayed. Display dialog box and screen in different threads.

Check this tutorial: http://www.javabeginner.com/learn-java/java-threads-tutorial

I think it will help.

  • Hi, I know my code does not exist something to kill the code but i m not getting any method to kill the thread in blackberry. – ricky khatri Aug 31 '12 at 06:39
  • To stop a thread declare a boolean variable, let say `stopFlag` in your thread, and check this variable in the thread `run()` method. When `stopFlag==true`, then invoke `return;` from your thread `run()` method. –  Aug 31 '12 at 06:47