Runtime.getRuntime().addShutdownHook(shutdownHook);
boolean stop = false;
do {
EventSet eventSet = eventQueue.remove();
long eventIniTime = System.currentTimeMillis();
//int resumeVMtimes = 0;
for(EventIterator i = eventSet.eventIterator(); i.hasNext(); ) {
Event evt = i.nextEvent();
if(evt instanceof ClassPrepareEvent) {
ClassPrepareEvent cpe = (ClassPrepareEvent) evt;
ReferenceType refType = cpe.referenceType();
logClazz.debug("Loading: " + refType.name() + " [cl:" + refType.classLoader()+"]");
loadClassDebug(refType, cpe.thread());
} else if(evt instanceof ClassUnloadEvent) {
ClassUnloadEvent cue = (ClassUnloadEvent) evt;
logClazz.debug("Unloading: " + cue.className());
} else if(evt instanceof ThreadStartEvent) {
ThreadStartEvent tse = (ThreadStartEvent) evt;
threadEventDebug(tse.thread(), "Thread Start");
//logThread.debug("Thread Start: " + tse.thread().name());
} else if(evt instanceof ThreadDeathEvent) {
ThreadDeathEvent tde = (ThreadDeathEvent) evt;
threadEventDebug(tde.thread(), "Thread Death");
//resumeVMtimes++;
//tde.virtualMachine().resume();
//logThread.debug("Thread Death: " + tde.thread().name());
//SuspendVMTimed svt = new SuspendVMTimed(tde.virtualMachine(), 1000);
} else if(evt instanceof ExceptionEvent) {
ExceptionEvent exe = (ExceptionEvent) evt;
exceptionEventDebug(exe);
} else if(evt instanceof VMDisconnectEvent) {
log.debug("VMDisconnectEvent!");
stop = true;
}
}
eventTime += (System.currentTimeMillis() - eventIniTime);
//for(int i=0;i<resumeVMtimes;i++) {
// eventQueue.virtualMachine().resume();
//}
//resumeVMtimes = 0;
eventSet.resume();
//eventQueue.virtualMachine().resume();
} while(!stop);
}
catch(Throwable oops) {
oops.printStackTrace();