0
vm = launchTarget("com.sun.tools.example.trace.Hello", false);
EventQueue eventQ = vm.eventQueue();
boolean connected = true;
while (connected) {
     try {
          EventSet eventSet = queue.remove();
          EventIterator it = eventSet.eventIterator();
          while (it.hasNext()) {
               handleEvent(it.nextEvent());
          }
          eventSet.resume();
     } catch (InterruptedException exc) {
          // Ignore
     } catch (VMDisconnectedException discExc) {
          //handleDisconnectedException();
          break;
     }
}

After VMStartEvent virtual machine hang in this line

EventSet eventSet = queue.remove();

VM is launched with suspend = false. I use java 1.7

shruti1810
  • 3,920
  • 2
  • 16
  • 28
Santhosh
  • 11
  • 4
  • Hmm according to the Javadoc http://docs.oracle.com/javase/7/docs/jdk/api/jpda/jdi/com/sun/jdi/event/EventQueue.html remove will block until a new Event can be taken. So I would say that there's no event in the queue. The Suspend option on the other hand only means that the jvm will wait or not wait until a Debugger connected to it. So this are two separate things. – philnate Jun 11 '15 at 07:33
  • Can you explain with java code ? @philnate – Santhosh Jun 11 '15 at 09:07
  • I can't as I don't know much about this topic. But if you look up the javadoc for the EventQueue.remove() method, you'll see that it will block until a new event is available. And it looks like this should be what your loop is doing. So it's not clear to me what your problem is. For the suspend, simple try it once with true and once with false. If set to true, jvm will halt execution of your program until a Debugger connected to it. That's mainly useful during early startup debugging, which is otherwise hard to do. Btw. it's probably not a good idea to swallow the interruptedException. – philnate Jun 11 '15 at 09:42

0 Answers0