当前位置: 首页>>代码示例>>Java>>正文


Java State.WAITING属性代码示例

本文整理汇总了Java中java.lang.Thread.State.WAITING属性的典型用法代码示例。如果您正苦于以下问题:Java State.WAITING属性的具体用法?Java State.WAITING怎么用?Java State.WAITING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在java.lang.Thread.State的用法示例。


在下文中一共展示了State.WAITING属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: waitForInitialization

private void waitForInitialization(long threadID) throws InterruptedException {
	ThreadMXBean mbean = ManagementFactory.getThreadMXBean();
	boolean isWaiting = true;
	
	while (isWaiting) {
		ThreadInfo threadInfo = mbean.getThreadInfo(threadID);
		if (threadInfo == null) {
			Thread.sleep(50);
			continue;
		}
		
		if (threadInfo.getThreadState() == State.WAITING)
			isWaiting = false;
		else
			Thread.sleep(50);
	}
}
 
开发者ID:digidotcom,项目名称:XBeeJavaLibrary,代码行数:17,代码来源:DataReaderTest.java

示例6: setNewDataWorker

private void setNewDataWorker() {
	if (this.dataThread != null) {
		this.dataWorker.induceStop();
		if (this.dataThread != Thread.currentThread()) {
			State state = this.dataThread.getState();
			if (state == State.BLOCKED || state == State.WAITING)
				this.dataThread.interrupt();
		}
	}

	this.dataTasks = new LinkedBlockingQueue<DataTask>();
	this.dataWorker = new DataWorker(this, this.currentSession, this.dataTasks);
	this.dataThread = new Thread(dataWorker);
	this.dataThread.setName("Data Worker for " + this.currentSession);
	this.dataThread.start();
}
 
开发者ID:WSUV-CS420-Team4,项目名称:ParkingTracker,代码行数:16,代码来源:DataManager.java

示例7: getThreadDebugData

/** Returns an array list of debug information for all Java threads; useful for trying to diagnose the cause of odd behaviour.
 * 
 * @return An array list of debug information
 */
public static ArrayList<String> getThreadDebugData()
{
	ArrayList<String> strings = new ArrayList<String>();

	strings.add("------------------------------------------------------------");
	strings.add("Debugging information for Java virtual machine");
	ThreadInfo[] threads = ManagementFactory.getThreadMXBean().dumpAllThreads(true, true);
	for (ThreadInfo thread : threads)
	{
		if (thread.getThreadState() != State.WAITING)
		{
			strings.add("------------------------------------------------------------");
			strings.add(thread.getThreadName());
			strings.add("\tPID: " + thread.getThreadId() + " | Suspended: " + thread.isSuspended() + " | Native: " + thread.isInNative() + " | State: " + thread.getThreadState());
			if (thread.getLockedMonitors().length != 0)
			{
				strings.add("\tThread is waiting on monitor(s):");
				for (MonitorInfo monitor : thread.getLockedMonitors())
				{
					strings.add("\t\tLocked on:" + monitor.getLockedStackFrame());
				}
			}
			strings.add("\tStack trace:");

			StackTraceElement[] stack = thread.getStackTrace();
			for (int line = 0; line < stack.length; line++)
			{
				strings.add("\t\t" + stack[line].toString());
			}
		}
	}
	strings.add("------------------------------------------------------------");
	strings.add("End of debugging information");
	strings.add("------------------------------------------------------------");

	return strings;
}
 
开发者ID:PolyphasicDevTeam,项目名称:NoMoreOversleeps,代码行数:41,代码来源:DebugHandler.java

示例8: 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

示例9: isWaiting

public boolean isWaiting()
{
    if( _thread != null && _thread.getState() == State.WAITING )
    {
        return true;
    }
    return false;
}
 
开发者ID:mleoking,项目名称:PhET,代码行数:8,代码来源:TriangulationProcess.java

示例10: checkActionIsPrepared

private boolean checkActionIsPrepared() {
	if (WifiReceiver.getInstance().isConnected()
			&& ServiceManager.getInstance().isDmcOpen()) {
		if (Thread.currentThread().getState() == State.WAITING) {
			return false;
		}
		return true;
	} else {
		return false;
	}
}
 
开发者ID:jasoncn90,项目名称:dlna-for-android,代码行数:11,代码来源:ActionManager.java

示例11: 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

示例12: shutdownThreads

public static void shutdownThreads() {
	if (persistenceThread != null) {
		worker.induceStop();
		State state = persistenceThread.getState();
		int tasks = worker.getNumTasks();
		if (tasks == 0 && (state == State.BLOCKED || state == State.WAITING))
			persistenceThread.interrupt();
		persistenceThread = null;
	}
}
 
开发者ID:WSUV-CS420-Team4,项目名称:ParkingTracker,代码行数:10,代码来源:Utils.java

示例13: requestImgDownload

public void requestImgDownload(String img_url, boolean fullScreen, TAImageDataHandler handler){
	try{
		Queue<doImgDownloadElem> msgs = imgDownThread.getpMsgs();
		doImgDownloadElem elem = new doImgDownloadElem(img_url, handler);
		elem.setFullScreen(fullScreen);
		msgs.add(elem);
		if(imgDownThread.getState() == State.WAITING){
			synchronized (msgs) {
				msgs.notify();
			}
		}
	}catch(final Exception ex){
		ex.printStackTrace();
	}
}
 
开发者ID:Easygor,项目名称:OpenTalkOn-Android-Chat-API,代码行数:15,代码来源:TAImgDownloader.java

示例14: isWaiting

public boolean isWaiting() {
  if (_thread != null && _thread.getState() == State.WAITING) {
    return true;
  }
  return false;
}
 
开发者ID:perunlabs,项目名称:jsolid,代码行数:6,代码来源:TriangulationProcess.java

示例15: run

@Override
public void run() {
    ExecutorService executorService = ThreadPool.pool;
    while (true) {
        Thread[] leastThreads = new Thread[Thread.activeCount()];
        int length = Thread.enumerate(leastThreads);

        boolean isAllWaiting = false;
        for (int i = 0; i < leastThreads.length; i++) {
            Thread thread = leastThreads[i];
            System.out.println("thread: " + thread.toString());
            System.out.println(thread.getState());

            System.out.println("thread.getState() == State.WAITING: "
                    + (thread.getState() == State.WAITING));

            if (thread.getName().startsWith("pool")) {
                if (thread.getState() == State.WAITING) {
                    isAllWaiting = true;
                    // thread.interrupt();
                    // System.out.println("等待线程结束:" + thread);
                } else {
                    isAllWaiting = false;
                }
            }
            // System.out.println(Thread.currentThread().getId());
        }
        if (isAllWaiting) {
            executorService.shutdownNow();
            if (executorService.isShutdown()) {
                System.out.println("pool.isShutdown() ================= "
                        + executorService.isShutdown());
                shutDowned();
                return;
            }
        }
        try {
            Thread.currentThread().sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:blademainer,项目名称:common_utils,代码行数:43,代码来源:ThreadPool.java


注:本文中的java.lang.Thread.State.WAITING属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。