本文整理汇总了Java中com.sun.jdi.ThreadReference.isCollected方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadReference.isCollected方法的具体用法?Java ThreadReference.isCollected怎么用?Java ThreadReference.isCollected使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.jdi.ThreadReference
的用法示例。
在下文中一共展示了ThreadReference.isCollected方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resume
import com.sun.jdi.ThreadReference; //导入方法依赖的package包/类
@Override
public void resume() {
/**
* To ensure that all threads are fully resumed when the VM is resumed, make sure the suspend count
* of each thread is no larger than 1.
* Notes: Decrementing the thread' suspend count to 1 is on purpose, because it doesn't break the
* the thread's suspend state, and also make sure the next instruction vm.resume() is able to resume
* all threads fully.
*/
for (ThreadReference tr : DebugUtility.getAllThreadsSafely(this)) {
while (!tr.isCollected() && tr.suspendCount() > 1) {
tr.resume();
}
}
vm.resume();
}
示例2: resumeThread
import com.sun.jdi.ThreadReference; //导入方法依赖的package包/类
/**
* Resume the thread the times as it has been suspended.
*
* @param thread
* the thread reference
*/
public static void resumeThread(ThreadReference thread) {
// if thread is not found or is garbage collected, do nothing
if (thread == null || thread.isCollected()) {
return;
}
try {
int suspends = thread.suspendCount();
for (int i = 0; i < suspends; i++) {
/**
* Invoking this method will decrement the count of pending suspends on this thread.
* If it is decremented to 0, the thread will continue to execute.
*/
thread.resume();
}
} catch (ObjectCollectedException ex) {
// ObjectCollectionException can be thrown if the thread has already completed (exited) in the VM when calling suspendCount,
// the resume operation to this thread is meanness.
}
}
示例3: getThread
import com.sun.jdi.ThreadReference; //导入方法依赖的package包/类
/**
* Get the ThreadReference instance by the thread id.
* @param debugSession
* the debug session
* @param threadId
* the thread id
* @return the ThreadReference instance
*/
public static ThreadReference getThread(IDebugSession debugSession, long threadId) {
for (ThreadReference thread : getAllThreadsSafely(debugSession)) {
if (thread.uniqueID() == threadId && !thread.isCollected()) {
return thread;
}
}
return null;
}