本文整理汇总了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));
}
示例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);
}
示例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));
}
示例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)
);
}
示例5: tryToExecute
import org.snmp4j.util.WorkerTask; //导入依赖的package包/类
public boolean tryToExecute(WorkerTask task) {
execute(task);
return true;
}
示例6: ContextfulWorkerTask
import org.snmp4j.util.WorkerTask; //导入依赖的package包/类
private ContextfulWorkerTask(WorkerTask task, T context) {
this.task = task;
this.context = context;
}