List of usage examples for java.lang Thread MIN_PRIORITY
int MIN_PRIORITY
To view the source code for java.lang Thread MIN_PRIORITY.
Click Source Link
From source file:gda.gui.text.parameter.EpicsPanelParameterListener.java
@Override public void vetoableChange(final PropertyChangeEvent e) throws PropertyVetoException { if (putTimeOut != null) { java.awt.Component c = null; Object obj = e.getSource(); if (obj instanceof ParametersPanelBuilder.ParameterChangeEventSource) { Object field = ((ParametersPanelBuilder.ParameterChangeEventSource) obj).parameterField.field; if (field instanceof java.awt.Component) { c = (java.awt.Component) field; }/* ww w . jav a 2s .c o m*/ } if (c != null) c.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.WAIT_CURSOR)); vetoableChangeinNewThread(e); if (c != null) c.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.DEFAULT_CURSOR)); } else { Thread t = uk.ac.gda.util.ThreadManager.getThread(new Runnable() { @Override public void run() { try { vetoableChangeinNewThread(e); } catch (Exception ex) { exceptionUtils.logException(logger, "vetoableChange", ex); } } }); t.setPriority(java.lang.Thread.MIN_PRIORITY); t.start(); } }
From source file:com.salas.bb.whatshot.LinkResolver.java
/** * Creates a link resolver for a given listener. * * @param listener listner./*from w ww.j a va 2 s . c o m*/ * * @throws IllegalArgumentException if listener is <code>NULL</code>. */ public LinkResolver(ILinkResolverListener listener) { if (listener == null) throw new IllegalArgumentException("Listener can't be NULL"); this.listener = listener; executor = ExecutorFactory .createPooledExecutor(new NamingThreadFactory("Link Resolver", Thread.MIN_PRIORITY), 5, 1000); }
From source file:com.searchcode.app.jobs.IndexGitRepoJob.java
public void execute(JobExecutionContext context) throws JobExecutionException { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); while (CodeIndexer.shouldPauseAdding()) { Singleton.getLogger().info("Pausing parser."); return;//from w ww.j ava2 s . c o m } // Pull the next repo to index from the queue UniqueRepoQueue repoQueue = Singleton.getUniqueGitRepoQueue(); RepoResult repoResult = repoQueue.poll(); AbstractMap<String, Integer> runningIndexGitRepoJobs = Singleton.getRunningIndexRepoJobs(); if (repoResult != null && !runningIndexGitRepoJobs.containsKey(repoResult.getName())) { Singleton.getLogger().info("Indexing " + repoResult.getName()); try { runningIndexGitRepoJobs.put(repoResult.getName(), (int) (System.currentTimeMillis() / 1000)); JobDataMap data = context.getJobDetail().getJobDataMap(); String repoName = repoResult.getName(); String repoRemoteLocation = repoResult.getUrl(); String repoUserName = repoResult.getUsername(); String repoPassword = repoResult.getPassword(); String repoBranch = repoResult.getBranch(); String repoLocations = data.get("REPOLOCATIONS").toString(); this.LOWMEMORY = Boolean.parseBoolean(data.get("LOWMEMORY").toString()); // Check if sucessfully cloned, and if not delete and restart boolean cloneSucess = checkCloneUpdateSucess(repoLocations + repoName); if (cloneSucess == false) { // Delete the folder and delete from the index try { FileUtils.deleteDirectory(new File(repoLocations + "/" + repoName + "/")); CodeIndexer.deleteByReponame(repoName); } catch (IOException ex) { Singleton.getLogger().warning("ERROR - caught a " + ex.getClass() + " in " + this.getClass() + "\n with message: " + ex.getMessage()); } } deleteCloneUpdateSuccess(repoLocations + "/" + repoName); String repoGitLocation = repoLocations + "/" + repoName + "/.git/"; File f = new File(repoGitLocation); boolean existingRepo = f.exists(); boolean useCredentials = repoUserName != null && !repoUserName.isEmpty(); RepositoryChanged repositoryChanged = null; if (existingRepo) { repositoryChanged = this.updateGitRepository(repoName, repoRemoteLocation, repoUserName, repoPassword, repoLocations, repoBranch, useCredentials); } else { repositoryChanged = this.cloneGitRepository(repoName, repoRemoteLocation, repoUserName, repoPassword, repoLocations, repoBranch, useCredentials); } // Write file indicating we have sucessfully cloned createCloneUpdateSuccess(repoLocations + "/" + repoName); // If the last index was not sucessful, then trigger full index boolean indexsuccess = checkIndexSucess(repoGitLocation); if (repositoryChanged.isChanged() || indexsuccess == false) { Singleton.getLogger().info("Update found indexing " + repoRemoteLocation); this.updateIndex(repoName, repoLocations, repoRemoteLocation, existingRepo, repositoryChanged); } } finally { // Clean up the job runningIndexGitRepoJobs.remove(repoResult.getName()); } } }
From source file:gate.Main.java
/** Run the user interface. */ protected static void runGui() throws GateException { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); // initialise the library and load user CREOLE directories try {//from ww w. ja va2 s . co m Gate.init(); } catch (Throwable t) { log.error("Problem while initialising GATE", t); int selection = JOptionPane.showOptionDialog(null, "Error during initialisation:\n" + t.toString() + "\nDo you still want to start GATE?", "GATE", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, new String[] { "Cancel", "Start anyway" }, "Cancel"); if (selection != 1) { System.exit(1); } } //create the main frame, show it SwingUtilities.invokeLater(new Runnable() { @Override public void run() { GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice().getDefaultConfiguration(); //this needs to run before any GUI component is constructed. applyUserPreferences(); //all the defaults tables have been updated; build the GUI frame = MainFrame.getInstance(gc); if (DEBUG) Out.prln("constructing GUI"); // run the GUI frame.setTitleChangable(true); frame.setTitle(name + " " + version + " build " + build); // Set title from Java properties String title = System.getProperty(GateConstants.TITLE_JAVA_PROPERTY_NAME); if (title != null) { frame.setTitle(title); } // if frame.setTitleChangable(false); // Set icon from Java properties // iconName could be absolute or "gate:/img/..." String iconName = System.getProperty(GateConstants.APP_ICON_JAVA_PROPERTY_NAME); if (iconName != null) { try { frame.setIconImage(Toolkit.getDefaultToolkit().getImage(new URL(iconName))); } catch (MalformedURLException mue) { log.warn("Could not load application icon.", mue); } } // if // Validate frames that have preset sizes frame.validate(); // Center the window Rectangle screenBounds = gc.getBounds(); Dimension screenSize = screenBounds.getSize(); Dimension frameSize = frame.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); frame.setVisible(true); //load session if required and available; //do everything from a new thread. Runnable runnable = new Runnable() { @Override public void run() { try { File sessionFile = Gate.getUserSessionFile(); if (sessionFile.exists()) { MainFrame.lockGUI("Loading saved session..."); PersistenceManager.loadObjectFromFile(sessionFile); } } catch (Exception e) { log.warn("Failed to load session data", e); } finally { MainFrame.unlockGUI(); } } }; Thread thread = new Thread(Thread.currentThread().getThreadGroup(), runnable, "Session loader"); thread.setPriority(Thread.MIN_PRIORITY); thread.start(); } }); registerCreoleUrls(); }
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 w w . j a v a2s . c om */ 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:org.xwiki.extension.job.history.internal.DefaultExtensionJobHistory.java
@Override public void initialize() throws InitializationException { load();/* w w w .j a v a 2 s .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.mythtv.client.MainApplication.java
private static void initImageLoader(Context context) { File cacheDir = new File(context.getCacheDir(), "images"); if (!cacheDir.exists()) { cacheDir.mkdir();/*from www .j a v a2 s .c o m*/ } // This configuration tuning is custom. You can tune every option, you may tune some of them, // or you can create default configuration by // ImageLoaderConfiguration.createDefault(this); // method. ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).threadPoolSize(5) .threadPriority(Thread.MIN_PRIORITY + 3).denyCacheImageMultipleSizesInMemory() .memoryCache(new WeakMemoryCache()).discCache(new UnlimitedDiscCache(cacheDir)).build(); // Initialize ImageLoader with configuration. ImageLoader.getInstance().init(config); L.disableLogging(); }
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);//from w w w . j a v a 2 s . c o m thread.setPriority(Thread.MIN_PRIORITY); thread.start(); waitForThreadToFinish(thread); }
From source file:BufferedImageThread.java
public void start() { thread = new Thread(this); thread.setPriority(Thread.MIN_PRIORITY); thread.start(); }
From source file:com.adito.rss.FeedManager.java
/** * Start checking for feed updates//from ww w. j av a 2 s . c om * * @throws IllegalStateException if already updating */ public void startUpdating() { if (running) { throw new IllegalStateException("Already updating."); } try { loadAvailable(); } catch (Exception e) { log.error("Failed to get initial feeds. Next update attempt will occur in 4 hours", e); interval = FOUR_HOURS_MILLIS; } thread = new Thread(this, "FeedManager"); thread.setPriority(Thread.MIN_PRIORITY); running = true; if (!isTestMode()) { thread.start(); } }