當前位置: 首頁>>代碼示例>>Java>>正文


Java State.TIMED_WAITING屬性代碼示例

本文整理匯總了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;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:21,代碼來源:OverviewController.java

示例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;
    }
  }
}
 
開發者ID:perunlabs,項目名稱:jsolid,代碼行數:16,代碼來源:TriangulationProcess.java

示例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 );
        }
    }
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:18,代碼來源:TriangulationProcess.java

示例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;
        }
    }
}
 
開發者ID:mleoking,項目名稱:PhET,代碼行數:24,代碼來源:TriangulationProcess.java

示例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);
    }
  }
}
 
開發者ID:perunlabs,項目名稱:jsolid,代碼行數:12,代碼來源:TriangulationProcess.java

示例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();
		}
	}
}
 
開發者ID:Protryon,項目名稱:AvunaHTTPD-Java,代碼行數:13,代碼來源:Buffer.java

示例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);
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:36,代碼來源:EnsembleTestRunner.java

示例8: waken

public void waken() {
    if (currentthread.getState() == State.TIMED_WAITING) {
        currentthread.interrupt();
    }
}
 
開發者ID:htools,項目名稱:htools,代碼行數:5,代碼來源:ThreadedScheduler.java


注:本文中的java.lang.Thread.State.TIMED_WAITING屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。