本文整理匯總了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();
}
}