开发者

Program works in Eclipse debugger but not anywhere else...?

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

  1. making the class public
  2. add a static main method making it a Java application
  3. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜