/** * Resumes every thread in this group and recursively in all its * subgroups. * * @see Thread#resume * @see #suspend * * @deprecated Requires deprecated method {@link Thread#resume()}. */ @SuppressWarnings("deprecation") @Deprecated public final void resume() { synchronized (threadRefs) { for (Thread thread : threads) { thread.resume(); } } synchronized (groups) { for (ThreadGroup group : groups) { group.resume(); } } }
public void run() { try { t.suspend(); l.countDown(); Thread.sleep(seconds * 1000); t.resume(); } catch (Exception e) { LOG.error("Error suspending thread", e); } } };
ctx.thread.stop(); } else if ("resume".equalsIgnoreCase(action)) { ctx.thread.resume(); } else if ("suspend".equalsIgnoreCase(action)) { ctx.thread.suspend();
ctx.thread.stop(); } else if ("resume".equalsIgnoreCase(action)) { ctx.thread.resume(); } else if ("suspend".equalsIgnoreCase(action)) { ctx.thread.suspend();
thread.resume();
Timer timer=new Timer(); // for each thread 't': t.suspend(); final Thread tFinal=t; // just a shortcut to allow my TimerTask to access 't' (alternatively you can // have an explicit constructor for your TimerTask, and pass 't' to it) timer.schedule( new TimerTask() { @Override public void run() { tFinal.resume(); } }, YOUR_RANDOM_VALUE);
@SuppressWarnings("deprecation") // suspends/resumes threads intentionally @SuppressForbidden(reason = "suspends/resumes threads intentionally") protected void resumeThreads(Set<Thread> threads) { for (Thread thread : threads) { thread.resume(); } } }
private void resumeThreads() { Set<Thread> threadSet = Thread.getAllStackTraces().keySet(); // List every thread in the group for (Thread t : threadSet) { if (t.getName().startsWith(GENERATOR_THREAD) || t.getName().startsWith(IMPORTER_THREAD) || t.getName().startsWith(EXPORTER_THREAD) || t.getName().startsWith(PROJECT_THREAD) || t.getName().startsWith(STATISTICS_THREAD) || t.getName().startsWith(PREVIEW_THREAD)) { if (t.isAlive()) { t.resume(); } } } }
/** * Resumes every thread in this group and recursively in all its * subgroups. * * @see Thread#resume * @see #suspend * * @deprecated Requires deprecated method {@link Thread#resume()}. */ @SuppressWarnings("deprecation") @Deprecated public final void resume() { synchronized (threadRefs) { for (Thread thread : threads) { thread.resume(); } } synchronized (groups) { for (ThreadGroup group : groups) { group.resume(); } } }
/** * Resumes every thread in this group and recursively in all its * subgroups. * * @see Thread#resume * @see #suspend * * @deprecated Requires deprecated method {@link Thread#resume()}. */ @SuppressWarnings("deprecation") @Deprecated public final void resume() { synchronized (threadRefs) { for (Thread thread : threads) { thread.resume(); } } synchronized (groups) { for (ThreadGroup group : groups) { group.resume(); } } }
/** * Resumes every thread in this group and recursively in all its * subgroups. * * @see Thread#resume * @see #suspend * * @deprecated Requires deprecated method {@link Thread#resume()}. */ @SuppressWarnings("deprecation") @Deprecated public final void resume() { synchronized (threadRefs) { for (Thread thread : threads) { thread.resume(); } } synchronized (groups) { for (ThreadGroup group : groups) { group.resume(); } } }
/** * Resumes every thread in this group and recursively in all its * subgroups. * * @see Thread#resume * @see #suspend * * @deprecated Requires deprecated method {@link Thread#resume()}. */ @SuppressWarnings("deprecation") @Deprecated public final void resume() { synchronized (threadRefs) { for (Thread thread : threads) { thread.resume(); } } synchronized (groups) { for (ThreadGroup group : groups) { group.resume(); } } }
/** * Resumes every thread in this group and recursively in all its * subgroups. * * @see Thread#resume * @see #suspend * * @deprecated Requires deprecated method {@link Thread#resume()}. */ @SuppressWarnings("deprecation") @Deprecated public final void resume() { synchronized (threadRefs) { for (Thread thread : threads) { thread.resume(); } } synchronized (groups) { for (ThreadGroup group : groups) { group.resume(); } } }
/** * Resumes every thread in this group and recursively in all its * subgroups. * * @see Thread#resume * @see #suspend * * @deprecated Requires deprecated method {@link Thread#resume()}. */ @SuppressWarnings("deprecation") @Deprecated public final void resume() { synchronized (threadRefs) { for (Thread thread : threads) { thread.resume(); } } synchronized (groups) { for (ThreadGroup group : groups) { group.resume(); } } }
@Deprecated @SuppressWarnings("deprecation") public final void resume() { for (Thread thread : getThreadsCopy()) thread.resume(); for (ThreadGroup group : getChildrenCopy()) group.resume(); }
private void killThread(Thread t, boolean force) { if (!force) { try { t.resume(); } catch(Exception e) {/* ignore */}; try { t.start(); } catch(Exception e) {/* ignore */}; try { t.interrupt(); } catch(Exception e) {/* ignore */}; try { t.stop(new ThreadDoomError(name)); } catch(IllegalStateException e) {/* ignore */} catch(UnsupportedOperationException e) { try { t.stop(); } catch(IllegalStateException ee) {/* ignore */} } } else { try { t.interrupt(); } catch(Exception e) {/* ignore */}; trySocketInterrupt(t); tryStop(t); try { t.interrupt(); } catch(Exception e) {/* ignore */}; try { t.stop(new ThreadDoomError(name)); } catch(IllegalStateException e) {/* ignore */} catch(UnsupportedOperationException e) { try { t.stop(); } catch(IllegalStateException ee) {/* ignore */} } } }
@Test public void testBasicSuspendResume(){ if (verifyNoPropertyViolation("+cg.threads.break_yield")) { Thread t1 = new T1(); t1.start(); while (!isRunning) { Thread.yield(); } System.out.println("main suspending t1"); t1.suspend(); assertTrue(t1.getState() == Thread.State.RUNNABLE); pass = true; System.out.println("main resuming t1"); t1.resume(); try { System.out.println("main joining t1"); t1.join(); } catch (InterruptedException ix){ fail("t1.join got interrupted"); } System.out.println("main terminating after t1.join"); } }
t3.resume(); try { System.out.println("main joining t3");
t4.resume(); try { System.out.println("main joining t4");
ctx.thread.stop(); } else if ("resume".equalsIgnoreCase(action)) { ctx.thread.resume(); } else if ("suspend".equalsIgnoreCase(action)) { ctx.thread.suspend();