当前位置: 首页>>代码示例>>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;未经允许,请勿转载。