I have some code that will not run if I don't have a breakpoint. My speculation i开发者_StackOverflows 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!
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.
精彩评论