当前位置: 首页>>代码示例>>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;未经允许,请勿转载。