List of usage examples for java.lang Thread setPriority
public final void setPriority(int newPriority)
From source file:org.wso2.carbon.clustering.hazelcast.HazelcastGroupManagementAgent.java
private void connectMember(Member member) { if (!member.getDomain().equals(domain) || !subDomain.equals(member.getProperties().get("subDomain"))) { return;//ww w .j a v a 2 s. c om } if (!connectedMembers.contains(member)) { Thread th = new Thread(new MemberAdder(member)); th.setPriority(Thread.MAX_PRIORITY); th.start(); } }
From source file:org.xwiki.extension.job.history.internal.DefaultExtensionJobHistory.java
@Override public void initialize() throws InitializationException { load();// w ww. ja v a 2s. co m Thread saveThread = new Thread(new SaveRunnable()); saveThread.setName("XWiki's extension job history saving thread"); saveThread.setDaemon(true); saveThread.setPriority(Thread.MIN_PRIORITY); saveThread.start(); }
From source file:org.tsho.dmc2.managers.ManifoldsManager.java
private void launchThread() { plot.getPlotRenderer().setState(DmcPlotRenderer.STATE_NONE); Thread refreshJob = new RefreshThread(); refreshJob.start();/*from w ww . java2s . c o m*/ Thread plotJob = new PlotThread("DMCDUE - Manifoldes plotter", false); plotJob.setPriority(Thread.currentThread().getPriority() - 1); plotJob.start(); }
From source file:org.tsho.dmc2.managers.LyapunovManager.java
private void launchThread() { plot.getPlotRenderer().setState(DmcPlotRenderer.STATE_NONE); Thread refreshJob = new RefreshThread(); refreshJob.start();// ww w. ja v a 2s . c o m Thread plotJob = new PlotThread("DMCDUE - Lyapunov plotter", false); plotJob.setPriority(Thread.currentThread().getPriority() - 1); plotJob.start(); }
From source file:net.pms.util.BasicThreadFactory.java
@Override public Thread newThread(Runnable runnable) { String threadName;//w w w . j av a 2 s . c om switch (numVariables) { case 0: threadName = namePattern; break; case 1: threadName = String.format(Locale.ROOT, namePattern, threadNumber.getAndIncrement()); break; default: threadName = String.format(Locale.ROOT, namePattern, instancePoolNumber, threadNumber.getAndIncrement()); } Thread thread = new Thread(group, runnable, threadName, 0); if (thread.isDaemon()) { thread.setDaemon(false); } if (thread.getPriority() != threadPriority) { thread.setPriority(threadPriority); } return thread; }
From source file:org.apache.hadoop.fs.s3r.S3RFileSystem.java
/** * Get a named {@link ThreadFactory} that just builds daemon threads. * @param prefix name prefix for all threads created from the factory * @return a thread factory that creates named, daemon threads with * the supplied exception handler and normal priority *//*from w ww. ja v a 2 s .co m*/ private static ThreadFactory newDaemonThreadFactory(final String prefix) { final ThreadFactory namedFactory = getNamedThreadFactory(prefix); return new ThreadFactory() { @Override public Thread newThread(Runnable r) { Thread t = namedFactory.newThread(r); if (!t.isDaemon()) { t.setDaemon(true); } if (t.getPriority() != Thread.NORM_PRIORITY) { t.setPriority(Thread.NORM_PRIORITY); } return t; } }; }
From source file:eu.interedition.collatex.tools.CollationServer.java
public CollationServer(int maxParallelCollations, int maxCollationSize, String dotPath) { this.collationThreads = Executors.newFixedThreadPool(maxParallelCollations, new ThreadFactory() { private final AtomicLong counter = new AtomicLong(); @Override//w w w. j av a 2 s. c o m public Thread newThread(Runnable r) { final Thread t = new Thread(r, "collator-" + counter.incrementAndGet()); t.setDaemon(true); t.setPriority(Thread.MIN_PRIORITY); return t; } }); this.maxCollationSize = maxCollationSize; this.dotPath = dotPath; }
From source file:org.tsho.dmc2.managers.BifurcationManager.java
private void launchThread() { plot.getPlotRenderer().setState(DmcPlotRenderer.STATE_NONE); Thread refreshJob = new RefreshThread(); refreshJob.start();//from w w w. ja v a2 s.com Thread plotJob = new PlotThread("DMCDUE - Bifurcation plotter", false); plotJob.setPriority(Thread.currentThread().getPriority() - 1); plotJob.start(); }
From source file:org.dawnsci.commandserver.core.process.ProgressableProcess.java
/** * Call to start the process and broadcast status * updates. Subclasses may redefine what is done * on the start method, by default a thread is started * in daemon mode to run things.// w w w . jav a 2s . c om */ public void start() { if (isBlocking()) { run(); // Block until process has run. } else { final Thread thread = new Thread(this); thread.setDaemon(true); thread.setPriority(Thread.MAX_PRIORITY); thread.start(); } }
From source file:org.apparatus_templi.Coordinator.java
/** ** Wake the given driver, optionally creating a new thread for the {@link Driver}, optionally * automatically calling start() on the new thread. * /*from w w w.j a va 2 s.c o m*/ * @param driverName * the name of the {@link Driver} to wake. * @param autoStart * if true the driver's thread will be automatically started after creation * @param wakeTerminated * if true then drivers whose thread state is TERMINATED will have a new thread * assigned. * @return a reference to the woken Driver. */ private static synchronized Driver wakeDriver(String driverName, boolean autoStart, boolean wakeTerminated) { assert driverName != null : "given driver name can not be null"; // NOTE using containsKey() does not always work for String values (different hash code may // be generated) assert loadedDrivers.get(driverName) != null : "driver " + driverName + " must exist within the loaded drivers table"; Driver d = loadedDrivers.get(driverName); Thread t = driverThreads.get(d); assert d != null && t != null : "the driver and its thread must be valid objects"; if (t.getState() == Thread.State.TERMINATED && wakeTerminated) { Log.d(TAG, "restarting driver '" + d.getName() + "' of class '" + d.getClass() + "' of type '" + d.getClass().getName() + "'"); scheduledWakeUps.remove(d); driverThreads.remove(d); Thread newThread = new Thread(d); newThread.setPriority(Thread.MIN_PRIORITY); driverThreads.put(d, newThread); if (autoStart) { newThread.start(); } } else { try { scheduledWakeUps.remove(d); d.wake(); Log.d(TAG, "waking driver " + driverName); } catch (Exception e) { Log.d(TAG, "could not wake driver " + driverName); } } return d; }