本文整理汇总了Java中java.lang.Thread.State.TIMED_WAITING属性的典型用法代码示例。如果您正苦于以下问题:Java State.TIMED_WAITING属性的具体用法?Java State.TIMED_WAITING怎么用?Java State.TIMED_WAITING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.lang.Thread.State
的用法示例。
在下文中一共展示了State.TIMED_WAITING属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toThreadState
/** taken from sun.misc.VM
*
* Returns Thread.State for the given threadStatus
*/
private static Thread.State toThreadState(int threadStatus) {
if ((threadStatus & JVMTI_THREAD_STATE_RUNNABLE) != 0) {
return State.RUNNABLE;
} else if ((threadStatus & JVMTI_THREAD_STATE_BLOCKED_ON_MONITOR_ENTER) != 0) {
return State.BLOCKED;
} else if ((threadStatus & JVMTI_THREAD_STATE_WAITING_INDEFINITELY) != 0) {
return State.WAITING;
} else if ((threadStatus & JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT) != 0) {
return State.TIMED_WAITING;
} else if ((threadStatus & JVMTI_THREAD_STATE_TERMINATED) != 0) {
return State.TERMINATED;
} else if ((threadStatus & JVMTI_THREAD_STATE_ALIVE) == 0) {
return State.NEW;
} else {
return State.RUNNABLE;
}
}
示例2: isReadable
public boolean isReadable() {
if (_thread == null) {
return true;
} else {
synchronized (_thread) {
if (_thread.getState() == State.WAITING) {
return true;
} else if (_thread.getState() == State.TIMED_WAITING) {
// Make sure that it stays readable
_tcx.waitUntilNotified(true);
return true;
}
return false;
}
}
}
示例3: resume
public void resume()
{
if( _thread != null )
{
// Only force a resume when process is waiting for a notification
if( _thread.getState() == State.WAITING )
{
synchronized( _tcx )
{
_tcx.notify();
}
}
else if( _thread.getState() == State.TIMED_WAITING )
{
_tcx.waitUntilNotified( false );
}
}
}
示例4: isReadable
public boolean isReadable()
{
if( _thread == null )
{
return true;
}
else
{
synchronized( _thread )
{
if( _thread.getState() == State.WAITING )
{
return true;
}
else if( _thread.getState() == State.TIMED_WAITING )
{
// Make sure that it stays readable
_tcx.waitUntilNotified( true );
return true;
}
return false;
}
}
}
示例5: resume
public void resume() {
if (_thread != null) {
// Only force a resume when process is waiting for a notification
if (_thread.getState() == State.WAITING) {
synchronized (_tcx) {
_tcx.notify();
}
} else if (_thread.getState() == State.TIMED_WAITING) {
_tcx.waitUntilNotified(false);
}
}
}
示例6: unsafe_prepend
/** Only to be used for prepending data that was not successfully written, and was just pulled out. No other use is safe. */
protected void unsafe_prepend(byte[] buf, int offset, int length) {
synchronized (this.buf) {
System.arraycopy(buf, offset, this.buf, this.read - length, length);
this.read -= length;
this.length += length;
}
if (flushInterrupt != null && flushInterrupt.getState() == State.TIMED_WAITING) {
synchronized (flushInterrupt) {
flushInterrupt.notify();
}
}
}
示例7: TimeoutError
public TimeoutError() {
this.state = mainThread.getState();
StackTraceElement[] trace = mainThread.getStackTrace();
try {
if ((state == State.WAITING) || (state == State.TIMED_WAITING)) {
List<StackTraceElement> elements = new ArrayList<StackTraceElement>(Arrays.asList(trace));
long ownerId = mainThread.getId();
ThreadMXBean bean = ManagementFactory.getThreadMXBean();
ThreadInfo threadInfo = null;
long nextId = ownerId;
while (nextId != -1) {
threadInfo = bean.getThreadInfo(nextId, Integer.MAX_VALUE);
if (threadInfo == null) {
break; // the thread being blocked on has terminated
}
nextId = threadInfo.getLockOwnerId();
if (nextId == ownerId) {
break;
}
String threadName = threadInfo.getThreadName();
elements.add(new StackTraceElement(TimeoutError.class.getCanonicalName(), "THREAD_" + threadName, "STACK$TRACE", 1));
elements.addAll(Arrays.asList(threadInfo.getStackTrace()));
if (nextId == -1) {
break;
}
}
trace = elements.toArray(trace);
}
} catch (Exception e) {
LogUtil.error(e);
}
StackTraceElement[] newTrace = new StackTraceElement[trace.length+1];
newTrace[0] = new StackTraceElement(TimeoutError.class.getCanonicalName(), "ESTIMATED", "STACK$TRACE", 1);
System.arraycopy(trace, 0, newTrace, 1, trace.length);
setStackTrace(trace);
}
示例8: waken
public void waken() {
if (currentthread.getState() == State.TIMED_WAITING) {
currentthread.interrupt();
}
}