The following code segment:
private class ConnectionControl implements Runnable
{
public void run()
{
while( true )
{
if( !cnnct.isInMsgEmpty() )
System.out.println( "Incoming message: " + cnnct.getInMsg().getPayloadString() ) ;
}
}
}
Works when I run it in eclipse debugger and place a breakpoint at the System.out line. However, if I run it normally I don't get the "Incoming message..." output.
Any thoughts on why this would be or how even to debug it???
Ahh figured it out开发者_如何学运维... had a deadlock situation going on where two threads were using the same resource. Thanks for your help guys!
Cheers!
There are multiple ways to invoke Java code, depending on where you need it.
What you have shown is not enough to be self-standing, and should cause an error if you try to invoke it as an applet or a java application (java .... ConnectionControl). It may be that Eclipse can invoke a Runnable - I have not seen it though.
Try
- making the class public
- add a static main method making it a Java application
- put a message in the start of the main method so you can see it is invoked
You're already using System.out.println for your program output. Add some sysouts that output where you are in the code and the status of various variables.
I don't know how this is being called but from the code I see your if condition is always evaluating false.
精彩评论