本文整理汇总了Java中java.util.concurrent.ThreadPoolExecutor.isTerminated方法的典型用法代码示例。如果您正苦于以下问题:Java ThreadPoolExecutor.isTerminated方法的具体用法?Java ThreadPoolExecutor.isTerminated怎么用?Java ThreadPoolExecutor.isTerminated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.concurrent.ThreadPoolExecutor
的用法示例。
在下文中一共展示了ThreadPoolExecutor.isTerminated方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: migrateData
import java.util.concurrent.ThreadPoolExecutor; //导入方法依赖的package包/类
private void migrateData() throws SQLException{
executor = new ThreadPoolExecutor(margs.getThreadCount(), margs.getThreadCount(),
0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(),new ThreadPoolExecutor.CallerRunsPolicy());
for(TableMigrateInfo table:migrateTables){
if(!table.isError()){ //忽略已出错的拆分表
List<DataNodeMigrateInfo> detailList = table.getDataNodesDetail();
for(DataNodeMigrateInfo info:detailList){
executor.execute(new DataMigrateRunner(table, info.getSrc(), info.getTarget(), table.getTableName(), info.getTempFile()));
}
}
}
executor.shutdown();
while(true){
if(executor.isTerminated()){
break;
}
try {
Thread.sleep(200);
} catch (InterruptedException e) {
LOGGER.error("error",e);
}
}
}
示例2: run
import java.util.concurrent.ThreadPoolExecutor; //导入方法依赖的package包/类
/*******************
* Enumeration mode main function.
******************/
public void run() {
ThreadPoolExecutor tpe = (ThreadPoolExecutor)Executors.newFixedThreadPool(this._opts.getThreadCount());
ArrayList<TCPEndpoint> targets = this._opts.getTargets();
RMIEnumerator rmie = new RMIEnumerator(this._opts);
//Initialise the list of known attacks with the current program options
RMIAttackFactory.setProgramOptions(this._opts);
//Status
System.out.println("Scanning " + targets.size() + " target(s) for objects exposed via an RMI registry...");
System.out.println("");
//Pass all tasks to the thread pool executor
for(TCPEndpoint t: targets) {
tpe.execute(new EnumerationTask(t, rmie, this._opts));
}
//Shutdown the thread pool and wait for threads to finish executing
tpe.shutdown();
while(tpe.isTerminated() == false) { }
//Done
System.out.println("Successfully scanned " + targets.size() + " target(s) for objects exposed via RMI.");
//Clean up all attacks (e.g. stop proxies that were started to enumerate endpoints)
RMIAttackFactory.cleanUp();
}
示例3: rejectedExecution
import java.util.concurrent.ThreadPoolExecutor; //导入方法依赖的package包/类
public void rejectedExecution(Runnable r, ThreadPoolExecutor executor) {
if (!executor.isTerminated()) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
r.run();
}
}