本文整理汇总了Java中java.lang.Thread.State.TERMINATED属性的典型用法代码示例。如果您正苦于以下问题:Java State.TERMINATED属性的具体用法?Java State.TERMINATED怎么用?Java State.TERMINATED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类java.lang.Thread.State
的用法示例。
在下文中一共展示了State.TERMINATED属性的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;
}
}
示例2: testGC
@Test
public void testGC() throws Exception {
CountDownLatch done = new CountDownLatch(1);
Scheduler scheduler = RxSchedulers.fixedSize(1);
FinalizeSupport.finalize(scheduler, done::countDown);
Wrapper<Thread> worker = Wrapper.empty();
Observable.just(1)
.subscribeOn(scheduler)
.doOnNext(i -> worker.set(Thread.currentThread()))
.blockingSubscribe();
scheduler = null;
System.gc();
assertTrue(done.await(100, TimeUnit.MILLISECONDS));
assertNotNull(worker.get());
for (int i = 0; i < 20; i++) {
System.gc();
Thread.sleep(5);
if (worker.get().getState() == State.TERMINATED) {
return;
}
}
assertEquals(State.TERMINATED, worker.get().getState());
}
示例3: start
private void start()
{
if( _thread == null || _thread.getState() == State.TERMINATED )
{
_isTerminated = false;
_thread = new Thread( this, _algorithm.name() + "." + _tcx.getTriangulationMode() );
_thread.start();
sendEvent( TriangulationProcessEvent.Started );
}
else
{
// Triangulation already running. Terminate it so we can start a new
shutdown();
_restart = true;
}
}
示例4: connectionRequest
public String connectionRequest() {
if (crw == null || crw.getState() == State.TERMINATED) {
try {
System.out.println("Connection request START");
HostsLocal h = Ejb.lookupHostsBean().findByHwidAndSn(hwid, sn);
// crw = new ConnectionRequestWorker(url, conreqUser, conreqPass);
crw = new ConnectionRequestWorker(h);
setLastcrres("In progress");
crw.start();
} catch (FinderException ex) {
System.out.println("FinderException: " + ex.getLocalizedMessage());
setLastcrres(ex.getLocalizedMessage());
Logger.getLogger(HostsBean.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
System.out.println("Connection request no......");
}
return null;
}
示例5: trackAllocatedHashinatorBytes
private static synchronized void trackAllocatedHashinatorBytes(long bytes) {
final long allocated = m_allocatedHashinatorBytes.addAndGet(bytes);
if (allocated > HASHINATOR_GC_THRESHHOLD) {
hostLogger.warn(allocated + " bytes of hashinator data has been allocated");
if (m_emergencyGCThread == null || m_emergencyGCThread.getState() == State.TERMINATED) {
m_emergencyGCThread = new Thread(new Runnable() {
@Override
public void run() {
hostLogger.warn("Invoking System.gc() to recoup hashinator bytes");
System.gc();
try {
Thread.sleep(2000);
} catch (InterruptedException e) {}
hostLogger.info(m_allocatedHashinatorBytes.get() + " bytes of hashinator allocated after GC");
}
}, "Hashinator GC thread");
m_emergencyGCThread.start();
}
}
}
示例6: start
private void start()
{
if( _thread == null || _thread.getState() == State.TERMINATED )
{
_isTerminated = false;
_thread = new Thread( this, _algorithm.name() + "." + _tcx.getTriangulationMode() );
_thread.start();
sendEvent( TriangulationProcessEvent.Started );
}
else
{
// Triangulation already running. Terminate it so we can start a new
shutdown();
_restart = true;
}
}
示例7: startCountDownToExecution
/**
* Call to start or reset a count down to execution of the current state's
* command.
*/
private void startCountDownToExecution() {
try {
countDownSemaphore.acquire();
if (countDownThread == null
|| countDownThread.getState() == State.TERMINATED) {
countDownThread = new Thread(countDownRunnable);
countDownThread.start();
} else {
timeToExecution = BTN_PRESS_INTERVAL;
}
} catch (Exception e) {
Log.e(TAG, e.toString());
} finally {
countDownSemaphore.release();
}
}
示例8: start
public void start(VideoGridFragment videoGridFragment) {
if (mLibVlc == null) {
try {
mLibVlc = VLCInstance.getLibVlcInstance();
} catch (LibVlcException e) {
Log.e(TAG, "Can't obtain libvlc instance");
e.printStackTrace();
return;
}
}
isStopping = false;
if (mThread == null || mThread.getState() == State.TERMINATED) {
mVideoGridFragment = videoGridFragment;
mThread = new Thread(this);
mThread.start();
}
}
示例9: currentThreads
public static List<Thread> currentThreads() {
List<Thread> threads = Lists.newArrayList();
for (Thread thread : Thread.getAllStackTraces().keySet()) {
// DestroyJavaVM is a JVM thread that appears sporadically, easier to just filter it out
//
// AWT-AppKit is a JVM thread on OS X that appears during webdriver tests
//
// "process reaper" are JVM threads on linux that monitors subprocesses, these use a
// thread pool in jdk7 and so the threads stay around in the pool even after the
// subprocess ends, they show up here when mixing local container and javaagent
// container tests since javaagent container tests create subprocesses and then local
// container tests check for rogue threads and find these
if (thread.getState() != State.TERMINATED
&& !thread.getName().equals("DestroyJavaVM")
&& !thread.getName().equals("AWT-AppKit")
&& !thread.getName().equals("process reaper")) {
threads.add(thread);
}
}
return threads;
}
示例10: start
public void start(VideoGridFragment videoGridFragment) {
if (mLibVlc == null) {
try {
mLibVlc = Util.getLibVlcInstance();
} catch (LibVlcException e) {
Log.e(TAG, "Can't obtain libvlc instance");
e.printStackTrace();
return;
}
}
isStopping = false;
if (mThread == null || mThread.getState() == State.TERMINATED) {
mVideoGridFragment = videoGridFragment;
mThread = new Thread(this);
mThread.start();
}
}
示例11: connectionRequest
public String connectionRequest() {
if (crw == null || crw.getState() == State.TERMINATED) {
try {
System.out.println("Connection request START");
HostsLocal h = Ejb.lookupHostsBean().findByHwidAndSn(hwid, sn);
// crw = new ConnectionRequestWorker(url, conreqUser, conreqPass);
crw = new ConnectionRequestWorker(h);
crw.start();
} catch (FinderException ex) {
Logger.getLogger(HostsBean.class.getName()).log(Level.SEVERE, null, ex);
}
} else {
System.out.println("Connection request no......");
}
return null;
}
示例12: initialize
@Override
protected ConcurrentEnvironment initialize(Thread key, UncaughtExceptionHandler params) {
if (key.getState() == State.TERMINATED) {
//send an exception...
params.uncaughtException(key, new ThreadDeath());
}
if (key.isInterrupted()) {
params.uncaughtException(key, new InterruptedException());
}
X_Log.info(ConcurrencyServiceAbstract.class, "Initializing Concurrent Environment", key);
final ConcurrentEnvironment inited = initializeEnvironment(key, params);
inited.getThreads().forEach(t->
environments.put(new AbstractPair<>(t, params), inited)
);
return inited;
}
示例13: isSaturated
protected boolean isSaturated() {
if (getPoolSize() <= 3) {
return DEBUG;
}
int corePoolSize = getCorePoolSize();
int i = CountedTask.mNumRunning.get();
int size = mThreads.size();
if (i < corePoolSize || i < size) {
return true;
}
boolean z;
synchronized (mThreads) {
Iterator<Thread> it = mThreads.iterator();
size = 0;
while (it.hasNext()) {
State state = it.next().getState();
if (state == State.RUNNABLE || state == State.NEW) {
i = size + 1;
} else {
if (state == State.TERMINATED) {
it.remove();
}
i = size;
}
size = i;
}
}
z = size >= corePoolSize;
return z;
}
示例14: isConnected
/**
* Returns whether the {@link com.hackathon.continuum.ddmlib.AndroidDebugBridge} object is still connected to the adb daemon.
*/
public boolean isConnected() {
MonitorThread monitorThread = MonitorThread.getInstance();
if (mDeviceMonitor != null && monitorThread != null) {
return mDeviceMonitor.isMonitoring() && monitorThread.getState() != State.TERMINATED;
}
return false;
}
示例15: start
private void start() {
if (_thread == null || _thread.getState() == State.TERMINATED) {
_isTerminated = false;
_thread = new Thread(this, _algorithm.name() + "." + _tcx.getTriangulationMode());
_thread.start();
sendEvent(TriangulationProcessEvent.Started);
} else {
// Triangulation already running. Terminate it so we can start a new
shutdown();
_restart = true;
}
}