List of usage examples for java.lang Thread setPriority
public final void setPriority(int newPriority)
From source file:org.nuxeo.runtime.gf3.GF3Component.java
@Override public void registerContribution(Object contribution, String extensionPoint, ComponentInstance contributor) throws Exception { if (XP_WEB_APP.equals(extensionPoint)) { WebApplication app = (WebApplication) contribution; log.info("Async. Deploying WAR: " + app.getName() + "; context path: " + app.getContextPath() + " webRoot: " + app.getWebRoot()); Thread deployerThread = new Thread(new WarDeployer(app), "Deployer"); deployerThread.setPriority(Thread.MAX_PRIORITY); deployerThread.start();/*w ww . ja va2 s. c o m*/ } else if (XP_DATA_SOURCE.equals(extensionPoint)) { log.debug("GF3 ignoring extension point " + XP_DATA_SOURCE); } }
From source file:ja.centre.gui.concurrent.TaskSequence.java
public void run() { Thread thread = new Thread(new Runnable() { public void run() { runAndWaint();/*from ww w . j a v a 2s . c o m*/ } }); thread.setPriority(priority); thread.start(); }
From source file:org.nuxeo.runtime.gf3.GF3Component.java
@Override public void activate(ComponentContext context) throws Exception { Environment env = Environment.getDefault(); //this is handled in GlassFishServer.createTempDir() // String gf3Root = env.getHome().getAbsolutePath()+"/glassfish"; // System.out.println("Using GlassFish home: "+gf3Root); // System.setProperty(SystemPropertyConstants.INSTALL_ROOT_PROPERTY, gf3Root); // System.setProperty(SystemPropertyConstants.INSTANCE_ROOT_PROPERTY, gf3Root); File file = new File(env.getConfig(), "domain.xml"); if (file.exists()) { log.info("Starting GF3 server:" + file.toURI().toURL()); server = new GlassFishServer(file.toURI().toURL()); } else {/*from w ww . j a v a2 s . c o m*/ log.info("activate : Starting GF3 server with no domain.xml"); server = new GlassFishServer(8080); } file = new File(env.getConfig(), "default-web.xml"); if (file.exists()) { log.info("activate : GF3 server using default-web.xml:" + file.toURI().toURL()); server.setDefaultWebXml(file.toURI().toURL()); } // register RARs - this is a costly operation - do it in a new thread log.info("Async. Deploying RARs"); Thread deployerThread = new Thread(new RarDeployer(), "Deployer"); deployerThread.setPriority(Thread.MAX_PRIORITY); deployerThread.start(); }
From source file:net.sf.jabref.JabRefExecutorService.java
public void executeWithLowPriorityInOwnThreadAndWait(Runnable runnable) { Thread thread = new Thread(runnable); thread.setName("JabRef low prio"); startedThreads.add(thread);//w w w . jav a2 s .com thread.setPriority(Thread.MIN_PRIORITY); thread.start(); waitForThreadToFinish(thread); }
From source file:org.jboss.dashboard.factory.BasicFactoryElement.java
protected void addPeriodicTask(final Method m, final long sleepInterval) { if (getComponentScope().equals(Component.SCOPE_GLOBAL)) { Runnable periodicRunnable = new Runnable() { public void run() { while (true) { try { // Run here periodic task m.invoke(BasicFactoryElement.this); // Detect if we have to end the thread if (componentKillFlag) return; } catch (Throwable e) { log.error("Error invoking periodic task: ", e); }// www. ja v a 2 s. c o m try { long totalSlept = 0; while (totalSlept < sleepInterval) { Thread.sleep(1000); totalSlept += 1000; if (componentKillFlag) return; } } catch (InterruptedException e) { log.error("Error: ", e); } } } }; Thread thr = new Thread(periodicRunnable, getComponentName() + " thread"); thr.setPriority(Thread.MIN_PRIORITY); thr.setDaemon(true); thr.start(); } else { log.error("Cannot add periodic task for component " + getComponentName() + ". Scope is " + getComponentScope()); } }
From source file:org.rhq.core.pc.util.LoggingThreadFactory.java
/** * @see java.util.concurrent.ThreadFactory#newThread(Runnable) *///from w w w . j a va 2s .co m public Thread newThread(Runnable r) { Thread t = new Thread(group, r, poolName + "-" + threadNumber.getAndIncrement()); t.setDaemon(this.daemon); if (t.getPriority() != Thread.NORM_PRIORITY) { t.setPriority(Thread.NORM_PRIORITY); } t.setUncaughtExceptionHandler(this); return t; }
From source file:org.apache.axis2.clustering.management.DefaultGroupManagementAgent.java
public void applicationMemberAdded(Member member) { if (!members.contains(member)) { Thread th = new Thread(new MemberAdder(member)); th.setPriority(Thread.MAX_PRIORITY); th.start();/* w w w . j a va 2 s . co m*/ try { th.join(); } catch (InterruptedException ignore) { } } }
From source file:org.alfresco.repo.content.replication.ContentStoreReplicator.java
/** * Kick off the replication thread. If one is already busy, then this method does * nothing./*from w ww. j a va 2s . c o m*/ */ public synchronized void start() { if (busy) { return; } // create a low-priority, daemon thread to do the work Runnable runnable = new ReplicationRunner(); Thread thread = new Thread(runnable); thread.setName("ContentStoreReplicator"); thread.setPriority(Thread.MIN_PRIORITY); thread.setDaemon(true); // start it thread.start(); busy = true; }
From source file:net.sf.jabref.JabRefExecutorService.java
public void executeWithLowPriorityInOwnThread(final Runnable runnable, String name) { AutoCleanupRunnable target = new AutoCleanupRunnable(runnable, startedThreads); final Thread thread = new Thread(target); target.thread = thread;/*from w ww . j a v a 2 s . c o m*/ thread.setName("JabRef - " + name + " - low prio"); startedThreads.add(thread); thread.setPriority(Thread.MIN_PRIORITY); thread.start(); }
From source file:api.wiki.WikiNameApi2.java
private void processSpecific(String s, PeopleNameOption option, final ProgressCallback callback) { final TreeMap<String, String> values = getGenderNames(s); final float[] progressValues = ProgressUtil.getProgressValues(values.size()); int counter = 1; for (final String peopleName : values.values()) { final int c = counter++; callback.onProgressUpdate(progressValues[c]); Task<Void> task = new Task<Void>() { @Override// w w w . j ava 2s . c om protected Void call() throws Exception { final File file = processName(peopleName, option); Platform.runLater(new Runnable() { @Override public void run() { callback.onProgress(processFile(peopleName, file)); } }); return null; } }; Thread thread = new Thread(task); thread.setPriority(Thread.MAX_PRIORITY); thread.start(); } }