當前位置: 首頁>>代碼示例>>Java>>正文


Java WorkerTask類代碼示例

本文整理匯總了Java中org.snmp4j.util.WorkerTask的典型用法代碼示例。如果您正苦於以下問題:Java WorkerTask類的具體用法?Java WorkerTask怎麽用?Java WorkerTask使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


WorkerTask類屬於org.snmp4j.util包,在下文中一共展示了WorkerTask類的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testMultipleTasks

import org.snmp4j.util.WorkerTask; //導入依賴的package包/類
@Test
public void testMultipleTasks() throws Exception {
  final int taskCount = 50;
  final MockWorkerTask[] delegates = new MockWorkerTask[taskCount];
  for (int i = 0; i < taskCount; i++) {
    delegates[i] = new MockWorkerTask();
    final WorkerTask task = factory.createWorkerThread("task " + i,
        delegates[i], false);
    task.run();
  }

  final long start = System.currentTimeMillis();
  boolean done = false;
  while (!done && System.currentTimeMillis() - start < taskCount * 100) {
    done = true;
    for (int i = 0; i < taskCount; i++) {
      done = done && delegates[i].awaitReady(10);
    }
  }
  assertThat(done, is(true));
}
 
開發者ID:soulwing,項目名稱:tnm4j,代碼行數:22,代碼來源:WorkerTaskTest.java

示例2: createWorkerThread

import org.snmp4j.util.WorkerTask; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public WorkerTask createWorkerThread(String name, WorkerTask task,
    boolean daemon) {
  Thread thread = delegate.newThread(task);
  thread.setName(name);
  thread.setDaemon(daemon);
  return new ThreadWorkerTask(thread);
}
 
開發者ID:soulwing,項目名稱:tnm4j,代碼行數:12,代碼來源:Snmp4jThreadFactory.java

示例3: testSingleTask

import org.snmp4j.util.WorkerTask; //導入依賴的package包/類
@Test
public void testSingleTask() throws Exception {
  final MockWorkerTask delegate = new MockWorkerTask();
  final WorkerTask task = factory.createWorkerThread("some name",
    delegate, false);
  task.run();
  assertThat(delegate.awaitReady(1000), is(true));
}
 
開發者ID:soulwing,項目名稱:tnm4j,代碼行數:9,代碼來源:WorkerTaskTest.java

示例4: execute

import org.snmp4j.util.WorkerTask; //導入依賴的package包/類
public void execute(final WorkerTask task) {
  T context = contextHolder.remove(Thread.currentThread());
  executer.submit(
    new ContextfulWorkerTask(task, context)
  );
}
 
開發者ID:kaitoy,項目名稱:sneo,代碼行數:7,代碼來源:ContextfulWorkerPool.java

示例5: tryToExecute

import org.snmp4j.util.WorkerTask; //導入依賴的package包/類
public boolean tryToExecute(WorkerTask task) {
  execute(task);
  return true;
}
 
開發者ID:kaitoy,項目名稱:sneo,代碼行數:5,代碼來源:ContextfulWorkerPool.java

示例6: ContextfulWorkerTask

import org.snmp4j.util.WorkerTask; //導入依賴的package包/類
private ContextfulWorkerTask(WorkerTask task, T context) {
  this.task = task;
  this.context = context;
}
 
開發者ID:kaitoy,項目名稱:sneo,代碼行數:5,代碼來源:ContextfulWorkerPool.java


注:本文中的org.snmp4j.util.WorkerTask類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。