當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。