我即将为 Eclipse 实现一个调试器。为此,我想org.eclipse.core.runtime.jobs.Job;
在调试设备到达断点时使用 Objetct 来处理事件。在这种情况下thread.resume()
返回。即使线程被挂起,Job
也不会休眠:
Output:
program suspended
cannot sleep
<repeat to infinity>
这是代码:
@Override
protected IStatus run(IProgressMonitor monitor) {
while (isTerminated() == false) {
try {
if (thread.isSuspended() == true) {
System.out.println("program suspended");
if(sleep() == true) { // wait for someone to wake me up
System.out.println("job is sleeping");
} else {
System.out.println("cannot sleep");
}
} else {
thread.resume();
}
} catch (DebugException e) {
e.printStackTrace();
}
}
return Status.OK_STATUS;
}
感谢您的任何帮助。