0

I have some code that will not run if I don't have a breakpoint. My speculation is that the code gets executed too quickly, and the time between me allowing a breakpoint to continue lets a thread lock on to my code. It also doesn't get "caught" with my exception handling, so its not bad code, but when the breakpoint is there it will dive into the try further and do everything I want it to do

not sure how to get this to work without being in debug mode! I am considering wait() or sleep() functions but it seems like a silly workaround, let me know if there is a better way

Thread triggerService = new Thread(new Runnable(){
        public void run(){
            Looper.prepare();
              try{
                    // .......  code here does not get executed
                    // such as if statements or anything


                   Looper.loop();
              }catch(Exception ex){
                    System.out.println("Exception in triggerService Thread -- "+ex);
              }//end catch
        }//end run
  }, "myNewThread");
  triggerService.start();

Insight appreciated!

UmNyobe
  • 22,539
  • 9
  • 61
  • 90
CQM
  • 42,592
  • 75
  • 224
  • 366

1 Answers1

1

Code works fine for me. Is there any other code in you program? Have you inserted debug output? You could test if the run() method is executed.

Tobias
  • 9,170
  • 3
  • 24
  • 30
  • Hey! I just put in debug output and it does in fact go into the try statement. So that means it isn't evaluating the variables in my IF condition in time (this was redacted). I removed the if condition and it runs my further code. I'll have to find another way to do this conditionally – CQM Oct 10 '11 at 21:24
  • It was because the variables in the if condition were being set by another thread, and that thread wasn't done yet – CQM Oct 11 '11 at 00:30