本文整理汇总了Java中com.sun.jdi.VirtualMachine.eventQueue方法的典型用法代码示例。如果您正苦于以下问题:Java VirtualMachine.eventQueue方法的具体用法?Java VirtualMachine.eventQueue怎么用?Java VirtualMachine.eventQueue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jdi.VirtualMachine
的用法示例。
在下文中一共展示了VirtualMachine.eventQueue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: start
import com.sun.jdi.VirtualMachine; //导入方法依赖的package包/类
/**
* Starts retrieving events from the event queue of the specified virtual machine.
*
* @param vm
* the target virtual machine.
*/
@Override
public void start(VirtualMachine vm) {
if (isClosed) {
throw new IllegalStateException("This event hub is already closed.");
}
workingThread = new Thread(() -> {
EventQueue queue = vm.eventQueue();
while (true) {
try {
if (Thread.interrupted()) {
subject.onComplete();
return;
}
EventSet set = queue.remove();
boolean shouldResume = true;
for (Event event : set) {
try {
logger.fine("\nJDI Event: " + event + "\n");
} catch (VMDisconnectedException e) {
// do nothing
}
DebugEvent dbgEvent = new DebugEvent();
dbgEvent.event = event;
dbgEvent.eventSet = set;
subject.onNext(dbgEvent);
shouldResume &= dbgEvent.shouldResume;
}
if (shouldResume) {
set.resume();
}
} catch (InterruptedException e) {
isClosed = true;
subject.onComplete();
return;
} catch (VMDisconnectedException e) {
isClosed = true;
subject.onError(e);
return;
}
}
}, "Event Hub");
workingThread.start();
}