ElfsЯUs
ElfsЯUs

Reputation: 1218

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!

Upvotes: 0

Views: 1429

Answers (2)

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

Upvotes: 1

Speck
Speck

Reputation: 2309

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.

Upvotes: 0

Related Questions