本文整理汇总了Java中org.threadly.concurrent.PriorityScheduler.shutdown方法的典型用法代码示例。如果您正苦于以下问题:Java PriorityScheduler.shutdown方法的具体用法?Java PriorityScheduler.shutdown怎么用?Java PriorityScheduler.shutdown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.threadly.concurrent.PriorityScheduler
的用法示例。
在下文中一共展示了PriorityScheduler.shutdown方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: main
import org.threadly.concurrent.PriorityScheduler; //导入方法依赖的package包/类
public static void main(String[] args) throws IOException {
if (args.length < 1) {
System.err.println("Usage: java -cp build/libs/heapDumpAnalyzer.java " +
Parse.class.getName() + " dump.hprof");
System.exit(1);
}
Profiler pf = new Profiler(10);
PriorityScheduler scheduler = new PriorityScheduler(Runtime.getRuntime().availableProcessors() * 2);
long start = Clock.accurateForwardProgressingMillis();
try {
HprofParser parser = new HprofParser(scheduler, new File(args[0]));
if(args.length >= 2) {
pf.start();
}
parser.parse();
System.out.println("ParseTime:"+(Clock.accurateForwardProgressingMillis()-start));
System.out.println("---------------------");
long at = Clock.accurateForwardProgressingMillis();
parser.analyze();
System.out.println("---------------------");
System.out.println("AnalyseTime:"+(Clock.accurateForwardProgressingMillis()-at));
} finally {
if(args.length >= 2) {
pf.stop();
File f = File.createTempFile("profile", "out");
RandomAccessFile raf = new RandomAccessFile(f, "rw");
raf.write(pf.dump().getBytes());
raf.close();
}
System.out.println("---------------------");
System.out.println("TotalTime:"+(Clock.accurateForwardProgressingMillis()-start));
System.gc();
System.out.println("---------------------");
System.out.println("Used Memory:" + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
scheduler.shutdown();
}
}
示例2: disposePrioritySchedulerTasks
import org.threadly.concurrent.PriorityScheduler; //导入方法依赖的package包/类
/**
* prevents any future tasks from being submitted to the PriorityScheduler.
*
* @param executor PriorityScheduler to operate on
* @param recurringStop whether or not to stop recurring tasks as well
*/
public void disposePrioritySchedulerTasks(final PriorityScheduler executor, boolean recurringStop) {
if (recurringStop) {
if (this.recurring != null) {
executor.remove(this.recurring);
}
executor.shutdown();
} else {
executor.shutdown();
}
}
示例3: main
import org.threadly.concurrent.PriorityScheduler; //导入方法依赖的package包/类
/**
* Main function for starting execution of the gui.
*
* @param args String array representing arguments for execution
*/
public static void main(String[] args) {
Display display = null;
try {
display = new Display();
} catch (Throwable t) {
System.err.println("Exception starting gui: " + t.getMessage());
t.printStackTrace();
System.exit(1);
}
int cpus = Runtime.getRuntime().availableProcessors();
PriorityScheduler scheduler = new PriorityScheduler(cpus, false);
try {
//Instantiate the GUI part
try {
AmbushGraph gui = new AmbushGraph(scheduler, display);
/* Test graph:
Node head = new Node("head");
Node chain1s1 = new Node("chain1s1");
head.addChildNode(chain1s1);
Node chain2s1 = new Node("chain2s1");
head.addChildNode(chain2s1);
Node chain2s2 = new Node("chain2s2");
chain2s1.addChildNode(chain2s2);
Node chain2p1 = new Node("chain2p1");
Node chain2p2 = new Node("chain2p2");
chain2s2.addChildNode(chain2p1);
chain2s2.addChildNode(chain2p2);
Node merge = new Node("merge");
chain1s1.addChildNode(merge);
chain2p1.addChildNode(merge);
chain2p2.addChildNode(merge);
Node p1 = new Node("p1");
Node p1s1 = new Node("p1s1");
Node p1s2 = new Node("p1s2");
p1.addChildNode(p1s1);
p1.addChildNode(p1s2);
Node p2 = new Node("p2");
Node p3 = new Node("p3");
Node p4 = new Node("p4");
merge.addChildNode(p1);
merge.addChildNode(p2);
merge.addChildNode(p3);
merge.addChildNode(p4);
Node end = new Node("tail");
p1s1.addChildNode(end);
p1s2.addChildNode(end);
p2.addChildNode(end);
p3.addChildNode(end);
p4.addChildNode(end);
p4.addChildNode(new Node("fake tail"));
gui.updateGraphModel(head);*/
gui.updateGraphModel(ScriptGraphBuilder.buildGraph(args));
gui.runGuiLoop();
} finally {
if (! display.isDisposed()) {
display.dispose();
}
}
} finally {
scheduler.shutdown();
}
}
示例4: main
import org.threadly.concurrent.PriorityScheduler; //导入方法依赖的package包/类
public static void main(String args[]) {
if (args.length == 0) {
System.err.println("Must provide at least one valid path to inspect");
System.exit(1);
}
List<File> examineDirectories = new ArrayList<File>(args.length);
for (String path : args) {
File toInspectPath = new File(path);
if (! toInspectPath.exists()) {
throw new IllegalArgumentException("Path does not exist: " + path);
} else if (! toInspectPath.isDirectory()) {
throw new IllegalArgumentException("Path is not a directory: " + path);
}
examineDirectories.add(toInspectPath);
}
int threadCount = Runtime.getRuntime().availableProcessors();
final PriorityScheduler scheduler = new PriorityScheduler(threadCount, TaskPriority.High, 1000, false);
scheduler.execute(new Runnable() {
@Override
public void run() {
scheduler.prestartAllThreads();
}
});
try {
FileCrawler fc = new FileCrawler(scheduler);
if (EXCLUDE_HIDDEN) {
fc.addFilter(new HiddenFileFilter());
}
FileNameInspector fni = new FileNameInspector();
fc.addListener(fni);
DuplicateFileInspector dfi = new DuplicateFileInspector();
fc.addListener(dfi);
// blocks till computation is done
fc.crawlDirectories(examineDirectories);
List<File> renameFiles = fni.getNotableFiles();
String duplicateResult = dfi.getDuplicateAnalysis(scheduler);
{
if (! renameFiles.isEmpty()) {
System.out.println();
System.out.println("Files for possible rename: ");
Iterator<File> it = renameFiles.iterator();
while (it.hasNext()) {
System.out.println(it.next().getAbsolutePath());
}
}
}
{
if (! duplicateResult.isEmpty()) {
if (! renameFiles.isEmpty()) {
System.out.println();
}
System.out.println(duplicateResult);
}
}
System.out.println("\nDONE!!");
} catch (Throwable t) {
System.err.println("Thrown exception from main thread, shutting down");
t.printStackTrace(System.err);
scheduler.shutdownNow();
} finally {
scheduler.shutdown();
}
}
示例5: startProcessingFiles
import org.threadly.concurrent.PriorityScheduler; //导入方法依赖的package包/类
private static void startProcessingFiles(int encodeParallelCount,
final ConverterInterface converter,
final File destFolder, final File sourceFolder) {
int maxThreadCount = Math.max(encodeParallelCount + 1, THREAD_COUNT);
PriorityScheduler scheduler = new PriorityScheduler(maxThreadCount, TaskPriority.High, 10 * 1000, true);
try {
final File[] origDestFileArray = destFolder.listFiles();
final File[] sourceFileArray = sourceFolder.listFiles();
List<File> sourceFileList = makeValidSourceList(converter,
sourceFileArray,
destFolder,
origDestFileArray);
SchedulerService converterPool = new SchedulerServiceLimiter(scheduler, encodeParallelCount);
Map<File, Future<?>> jobs = converter.submitJobs(converterPool, sourceFileList, destFolder);
if (jobs.isEmpty()) {
deleteRemovedFiles(converter, origDestFileArray,
sourceFileArray,
destFolder);
} else {
scheduleKillTask(scheduler, converter, jobs, destFolder);
scheduler.scheduleWithFixedDelay(new Runnable() {
@Override
public void run() {
deleteRemovedFiles(converter, origDestFileArray,
sourceFolder.listFiles(),
destFolder);
}
}, 0, 1000 * 60 * 10, TaskPriority.Low);
// wait for all running processes to finish
waitForJobs(jobs);
}
} finally {
scheduler.shutdown();
}
}