本文整理汇总了Java中com.sun.jmx.snmp.tasks.Task类的典型用法代码示例。如果您正苦于以下问题:Java Task类的具体用法?Java Task怎么用?Java Task使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Task类属于com.sun.jmx.snmp.tasks包,在下文中一共展示了Task类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeTask
import com.sun.jmx.snmp.tasks.Task; //导入依赖的package包/类
public Runnable removeTask(Runnable task) {
stateCheck();
Runnable removed = null;
synchronized(jobList) {
int lg = jobList.indexOf(task);
if (lg >= 0) {
removed = jobList.remove(lg);
}
}
if (removed != null && removed instanceof Task)
((Task) removed).cancel();
return removed;
}
示例2: removeAll
import com.sun.jmx.snmp.tasks.Task; //导入依赖的package包/类
public void removeAll() {
stateCheck();
final Object[] jobs;
synchronized(jobList) {
jobs = jobList.toArray();
jobList.clear();
}
final int len = jobs.length;
for (int i=0; i<len ; i++) {
final Object o = jobs[i];
if (o!= null && o instanceof Task) ((Task)o).cancel();
}
}
示例3: createThreadPoolMock
import com.sun.jmx.snmp.tasks.Task; //导入依赖的package包/类
private ThreadPool createThreadPoolMock(String threadPoolName, int callTimes) {
ThreadPool mock = createMock(ThreadPool.class);
mock.submit( anyObject(Task.class), eq(threadPoolName));
expectLastCall().andReturn(createMock(Future.class)).times(callTimes);
replay(mock);
return mock;
}
示例4: submitTask
import com.sun.jmx.snmp.tasks.Task; //导入依赖的package包/类
/**
* Submit a task to be executed.
* Once a task is submitted, it is guaranteed that either
* {@link com.sun.jmx.snmp.tasks.Task#run() task.run()} or
* {@link com.sun.jmx.snmp.tasks.Task#cancel() task.cancel()} will be called.
* This implementation of TaskServer uses a thread pool to execute
* the submitted tasks.
* @param task The task to be executed.
* @exception IllegalArgumentException if the submitted task is null.
**/
public void submitTask(Task task) throws IllegalArgumentException {
submitTask((Runnable)task);
}