java.lang.Thread.resume()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.1k)|赞(0)|评价(0)|浏览(232)

本文整理了Java中java.lang.Thread.resume()方法的一些代码示例,展示了Thread.resume()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Thread.resume()方法的具体详情如下:
包路径:java.lang.Thread
类名称:Thread
方法名:resume

Thread.resume介绍

[英]Resumes a suspended thread.

First, the checkAccess method of this thread is called with no arguments. This may result in throwing a SecurityException (in the current thread).

If the thread is alive but suspended, it is resumed and is permitted to make progress in its execution.
[中]恢复挂起的线程。
首先,调用此线程的checkAccess方法时不带任何参数。这可能会导致抛出SecurityException(在当前线程中)。
如果线程处于活动状态但被挂起,它将被恢复并允许在执行过程中取得进展。

代码示例

代码示例来源:origin: robovm/robovm

/**
 * 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();
    }
  }
}

代码示例来源:origin: apache/pulsar

public void run() {
    try {
      t.suspend();
      l.countDown();
      Thread.sleep(seconds * 1000);
      t.resume();
    } catch (Exception e) {
      LOG.error("Error suspending thread", e);
    }
  }
};

代码示例来源:origin: scouter-project/scouter

ctx.thread.stop();
} else if ("resume".equalsIgnoreCase(action)) {
  ctx.thread.resume();
} else if ("suspend".equalsIgnoreCase(action)) {
  ctx.thread.suspend();

代码示例来源:origin: scouter-project/scouter

ctx.thread.stop();
} else if ("resume".equalsIgnoreCase(action)) {
  ctx.thread.resume();
} else if ("suspend".equalsIgnoreCase(action)) {
  ctx.thread.suspend();

代码示例来源:origin: apache/ignite

thread.resume();

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: com.strapdata.elasticsearch.test/framework

@SuppressWarnings("deprecation") // suspends/resumes threads intentionally
  @SuppressForbidden(reason = "suspends/resumes threads intentionally")
  protected void resumeThreads(Set<Thread> threads) {
    for (Thread thread : threads) {
      thread.resume();
    }
  }
}

代码示例来源:origin: org.gephi/desktop-branding

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();
      }
    }
  }
}

代码示例来源:origin: MobiVM/robovm

/**
 * 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();
    }
  }
}

代码示例来源:origin: com.bugvm/bugvm-rt

/**
 * 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();
    }
  }
}

代码示例来源:origin: com.gluonhq/robovm-rt

/**
 * 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();
    }
  }
}

代码示例来源:origin: ibinti/bugvm

/**
 * 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();
    }
  }
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * 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();
    }
  }
}

代码示例来源:origin: FlexoVM/flexovm

/**
 * 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();
    }
  }
}

代码示例来源:origin: com.jtransc/jtransc-rt

@Deprecated
@SuppressWarnings("deprecation")
public final void resume() {
  for (Thread thread : getThreadsCopy()) thread.resume();
  for (ThreadGroup group : getChildrenCopy()) group.resume();
}

代码示例来源:origin: gridkit/nanocloud

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 */}
    }
  }
}

代码示例来源:origin: javapathfinder/jpf-core

@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");
 }
}

代码示例来源:origin: javapathfinder/jpf-core

t3.resume();
try {
 System.out.println("main joining t3");

代码示例来源:origin: javapathfinder/jpf-core

t4.resume();
try {
 System.out.println("main joining t4");

代码示例来源:origin: io.github.scouter-project/scouter-agent-java

ctx.thread.stop();
} else if ("resume".equalsIgnoreCase(action)) {
  ctx.thread.resume();
} else if ("suspend".equalsIgnoreCase(action)) {
  ctx.thread.suspend();

相关文章