List of usage examples for java.lang Thread MAX_PRIORITY
int MAX_PRIORITY
To view the source code for java.lang Thread MAX_PRIORITY.
Click Source Link
From source file:com.arkatay.yada.codec.AudioEncoder.java
protected AudioEncoder(Mixer mixer) { // Create a logger for this class log = LogFactory.getLog(getClass()); this.mixer = mixer; // Create the thread thread = new Thread(this, "Tencoder"); thread.setPriority((Thread.NORM_PRIORITY + Thread.MAX_PRIORITY) / 2); // Reset list resetChannelsList = new LinkedList<Integer>(); pool = PacketPool.getPool();//w w w .ja v a2 s. com // Start in state off state = STATE_OFF; }
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();// ww w . jav a 2s . co m } else if (XP_DATA_SOURCE.equals(extensionPoint)) { log.debug("GF3 ignoring extension point " + XP_DATA_SOURCE); } }
From source file:imageviewer.system.ImageViewerClient.java
private void initialize(CommandLine args) { // First, process all the different command line arguments that we // need to override and/or send onwards for initialization. boolean fullScreen = (args.hasOption("fullscreen")) ? true : false; String dir = (args.hasOption("dir")) ? args.getOptionValue("dir") : null; String type = (args.hasOption("type")) ? args.getOptionValue("type") : "DICOM"; String prefix = (args.hasOption("client")) ? args.getOptionValue("client") : null; LOG.info("Java home environment: " + System.getProperty("java.home")); // Logging system taken care of through properties file. Check // for JAI. Set up JAI accordingly with the size of the cache // tile and to recycle cached tiles as needed. verifyJAI();/*from www. java2s .co m*/ TileCache tc = JAI.getDefaultInstance().getTileCache(); tc.setMemoryCapacity(32 * 1024 * 1024); TileScheduler ts = JAI.createTileScheduler(); ts.setPriority(Thread.MAX_PRIORITY); JAI.getDefaultInstance().setTileScheduler(ts); JAI.getDefaultInstance().setRenderingHint(JAI.KEY_CACHED_TILE_RECYCLING_ENABLED, Boolean.TRUE); // Set up the frame and everything else. First, try and set the // UI manager to use our look and feel because it's groovy and // lets us control the GUI components much better. try { UIManager.setLookAndFeel(new ImageViewerLookAndFeel()); LookAndFeelAddons.setAddon(ImageViewerLookAndFeelAddons.class); } catch (Exception exc) { LOG.error("Could not set imageViewer L&F."); } // Load up the ApplicationContext information... ApplicationContext ac = ApplicationContext.getContext(); if (ac == null) { LOG.error("Could not load configuration, exiting."); System.exit(1); } // Override the client node information based on command line // arguments...Make sure that the files are there, otherwise just // default to a local configuration. String hostname = new String("localhost"); try { hostname = InetAddress.getLocalHost().getHostName(); } catch (Exception exc) { } String[] gatewayConfigs = (prefix != null) ? (new String[] { "resources/server/" + prefix + "GatewayConfig.xml", (String) ac.getProperty(ApplicationContext.IMAGESERVER_GATEWAY_CONFIG), "resources/server/" + hostname + "GatewayConfig.xml", "resources/server/localGatewayConfig.xml" }) : (new String[] { (String) ac.getProperty(ApplicationContext.IMAGESERVER_GATEWAY_CONFIG), "resources/server/" + hostname + "GatewayConfig.xml", "resources/server/localGatewayConfig.xml" }); String[] nodeConfigs = (prefix != null) ? (new String[] { "resources/server/" + prefix + "NodeConfig.xml", (String) ac.getProperty(ApplicationContext.IMAGESERVER_CLIENT_NODE), "resources/server/" + hostname + "NodeConfig.xml", "resources/server/localNodeConfig.xml" }) : (new String[] { (String) ac.getProperty(ApplicationContext.IMAGESERVER_CLIENT_NODE), "resources/server/" + hostname + "NodeConfig.xml", "resources/server/localNodeConfig.xml" }); for (int loop = 0; loop < gatewayConfigs.length; loop++) { String s = gatewayConfigs[loop]; if ((s != null) && (s.length() != 0) && (!"null".equals(s))) { File f = new File(s); if (f.exists()) { ac.setProperty(ApplicationContext.IMAGESERVER_GATEWAY_CONFIG, s); break; } } } LOG.info("Using gateway config: " + ac.getProperty(ApplicationContext.IMAGESERVER_GATEWAY_CONFIG)); for (int loop = 0; loop < nodeConfigs.length; loop++) { String s = nodeConfigs[loop]; if ((s != null) && (s.length() != 0) && (!"null".equals(s))) { File f = new File(s); if (f.exists()) { ac.setProperty(ApplicationContext.IMAGESERVER_CLIENT_NODE, s); break; } } } LOG.info("Using client config: " + ac.getProperty(ApplicationContext.IMAGESERVER_CLIENT_NODE)); // Load the layouts and set the default window/level manager... LayoutFactory.initialize(); DefaultWindowLevelManager dwlm = new DefaultWindowLevelManager(); // Create the main JFrame, set its behavior, and let the // ApplicationPanel know the glassPane and layeredPane. Set the // menubar based on reading in the configuration menus. mainFrame = new JFrame("imageviewer"); try { ArrayList<Image> iconList = new ArrayList<Image>(); iconList.add(ImageIO.read(new File("resources/icons/mii.png"))); iconList.add(ImageIO.read(new File("resources/icons/mii32.png"))); mainFrame.setIconImages(iconList); } catch (Exception exc) { } mainFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); mainFrame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { int confirm = ApplicationPanel.getInstance().showDialog( "Are you sure you want to quit imageViewer?", null, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION, UIManager.getIcon("Dialog.shutdownIcon")); if (confirm == JOptionPane.OK_OPTION) { boolean hasUnsaved = SaveStack.getInstance().hasUnsavedItems(); if (hasUnsaved) { int saveResult = ApplicationPanel.getInstance().showDialog( "There is still unsaved data. Do you want to save this data in the local archive?", null, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_CANCEL_OPTION); if (saveResult == JOptionPane.CANCEL_OPTION) return; if (saveResult == JOptionPane.YES_OPTION) SaveStack.getInstance().saveAll(); } LOG.info("Shutting down imageServer local archive..."); try { ImageViewerClientNode.getInstance().shutdown(); } catch (Exception exc) { LOG.error("Problem shutting down imageServer local archive..."); } finally { System.exit(0); } } } }); String menuFile = (String) ApplicationContext.getContext().getProperty(ac.CONFIG_MENUS); String ribbonFile = (String) ApplicationContext.getContext().getProperty(ac.CONFIG_RIBBON); if (menuFile != null) { JMenuBar mb = new JMenuBar(); mb.setBackground(Color.black); MenuReader.parseFile(menuFile, mb); mainFrame.setJMenuBar(mb); ApplicationContext.getContext().setApplicationMenuBar(mb); } else if (ribbonFile != null) { RibbonReader rr = new RibbonReader(); JRibbon jr = rr.parseFile(ribbonFile); mainFrame.getContentPane().add(jr, BorderLayout.NORTH); ApplicationContext.getContext().setApplicationRibbon(jr); } mainFrame.getContentPane().add(ApplicationPanel.getInstance(), BorderLayout.CENTER); ApplicationPanel.getInstance().setGlassPane((JPanel) (mainFrame.getGlassPane())); ApplicationPanel.getInstance().setLayeredPane(mainFrame.getLayeredPane()); // Load specified plugins...has to occur after the menus are // created, btw. PluginLoader.initialize("config/plugins.xml"); // Detect operating system... String osName = System.getProperty("os.name"); ApplicationContext.getContext().setProperty(ApplicationContext.OS_NAME, osName); LOG.info("Detected operating system: " + osName); // Try and hack the searched library paths if it's windows so we // can add a local dll path... try { if (osName.contains("Windows")) { Field f = ClassLoader.class.getDeclaredField("usr_paths"); f.setAccessible(true); String[] paths = (String[]) f.get(null); String[] tmp = new String[paths.length + 1]; System.arraycopy(paths, 0, tmp, 0, paths.length); File currentPath = new File("."); tmp[paths.length] = currentPath.getCanonicalPath() + "/lib/dll/"; f.set(null, tmp); f.setAccessible(false); } } catch (Exception exc) { LOG.error("Error attempting to dynamically set library paths."); } // Get screen resolution... GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice() .getDefaultConfiguration(); Rectangle r = gc.getBounds(); LOG.info("Detected screen resolution: " + (int) r.getWidth() + "x" + (int) r.getHeight()); // Try and see if Java3D is installed, and if so, what version... try { VirtualUniverse vu = new VirtualUniverse(); Map m = vu.getProperties(); String s = (String) m.get("j3d.version"); LOG.info("Detected Java3D version: " + s); } catch (Throwable t) { LOG.info("Unable to detect Java3D installation"); } // Try and see if native JOGL is installed... try { System.loadLibrary("jogl"); ac.setProperty(ApplicationContext.JOGL_DETECTED, Boolean.TRUE); LOG.info("Detected native libraries for JOGL"); } catch (Throwable t) { LOG.info("Unable to detect native JOGL installation"); ac.setProperty(ApplicationContext.JOGL_DETECTED, Boolean.FALSE); } // Start the local client node to connect to the network and the // local archive running on this machine...Thread the connection // process so it doesn't block the imageViewerClient creating this // instance. We may not be connected to the given gateway, so the // socketServer may go blah... final boolean useNetwork = (args.hasOption("nonet")) ? false : true; ApplicationPanel.getInstance().addStatusMessage("ImageViewer is starting up, please wait..."); if (useNetwork) LOG.info("Starting imageServer client to join network - please wait..."); Thread t = new Thread(new Runnable() { public void run() { try { ImageViewerClientNode.getInstance( (String) ApplicationContext.getContext() .getProperty(ApplicationContext.IMAGESERVER_GATEWAY_CONFIG), (String) ApplicationContext.getContext() .getProperty(ApplicationContext.IMAGESERVER_CLIENT_NODE), useNetwork); ApplicationPanel.getInstance().addStatusMessage("Ready"); } catch (Exception exc) { exc.printStackTrace(); } } }); t.setPriority(9); t.start(); this.fullScreen = fullScreen; mainFrame.setUndecorated(fullScreen); // Set the view to encompass the default screen. if (fullScreen) { Insets i = Toolkit.getDefaultToolkit().getScreenInsets(gc); mainFrame.setLocation(r.x + i.left, r.y + i.top); mainFrame.setSize(r.width - i.left - i.right, r.height - i.top - i.bottom); } else { mainFrame.setSize(1100, 800); mainFrame.setLocation(r.x + 200, r.y + 100); } if (dir != null) ApplicationPanel.getInstance().load(dir, type); timer = new Timer(); timer.schedule(new GarbageCollectionTimer(), 5000, 2500); mainFrame.setVisible(true); }
From source file:org.apache.roller.weblogger.business.runnable.ThreadManagerImpl.java
public void initialize() throws InitializationException { // initialize tasks, making sure that each task has a tasklock record in the db List<RollerTask> webloggerTasks = new ArrayList<RollerTask>(); String tasksStr = WebloggerConfig.getProperty("tasks.enabled"); String[] tasks = StringUtils.stripAll(StringUtils.split(tasksStr, ",")); for (String taskName : tasks) { String taskClassName = WebloggerConfig.getProperty("tasks." + taskName + ".class"); if (taskClassName != null) { log.info("Initializing task: " + taskName); try { Class taskClass = Class.forName(taskClassName); RollerTask task = (RollerTask) taskClass.newInstance(); task.init(taskName);// w w w . j a v a 2s. c o m // make sure there is a tasklock record in the db TaskLock taskLock = getTaskLockByName(task.getName()); if (taskLock == null) { log.debug("Task record does not exist, inserting empty record to start with"); // insert an empty record taskLock = new TaskLock(); taskLock.setName(task.getName()); taskLock.setLastRun(new Date(0)); taskLock.setTimeAquired(new Date(0)); taskLock.setTimeLeased(0); // save it this.saveTaskLock(taskLock); } // add it to the list of configured tasks webloggerTasks.add(task); } catch (ClassCastException ex) { log.warn("Task does not extend RollerTask class", ex); } catch (WebloggerException ex) { log.error("Error scheduling task", ex); } catch (Exception ex) { log.error("Error instantiating task", ex); } } } // create scheduler TaskScheduler scheduler = new TaskScheduler(webloggerTasks); // start scheduler thread, but only if it's not already running if (schedulerThread == null && scheduler != null) { log.debug("Starting scheduler thread"); schedulerThread = new Thread(scheduler, "Roller Weblogger Task Scheduler"); // set thread priority between MAX and NORM so we get slightly preferential treatment schedulerThread.setPriority((Thread.MAX_PRIORITY + Thread.NORM_PRIORITY) / 2); schedulerThread.start(); } }
From source file:com.stimulus.archiva.search.StandardSearch.java
public synchronized void searchMessage() throws MessageSearchException { logger.debug("standard search executed {query='" + getSearchQuery() + "'}"); // this a gui operation, must come back fast Thread.currentThread().setPriority(Thread.MAX_PRIORITY); if (getSearchQuery() == null) { setSearchQuery(compileSearchQuery(viewFilter.getCriteria())); }//from www. ja va2 s. co m if (getSearchQuery().compareTo(oldQuery) != 0) { queryModified = true; oldQuery = getSearchQuery(); } if (queryModified) { analyzer = AnalyzerFactory.getAnalyzer(getLanguage(), AnalyzerFactory.Operation.SEARCH); query = getQuery(analyzer); queryModified = false; } if (sortModified) { sort = getSortPreference(); sortModified = false; } //if (filterModified) { queryFilter = getFilter(analyzer); filterModified = false; //} try { if ((openIndex == OpenIndex.SEARCH) || (openIndex == OpenIndex.SESSION && searchersModified)) { try { if (searchers != null) { try { logger.debug("//closing searchers"); // searchers.close(); } catch (Exception e) { } } searchers = getVolumeSearchers(); if (searchers == null) { logger.debug("there are no volumes to search"); init(); return; } searchersModified = false; } catch (MessageSearchException mse) { logger.error("failed to create volume searchers:" + mse.getMessage(), mse); init(); return; } } search(query, queryFilter, sort); } catch (MessageSearchException mse) { logger.debug("standard search no volumes available for searching:" + mse.getMessage(), mse); init(); } finally { // reset searchQuery searchQuery = null; filterQuery = null; } }
From source file:org.jajuk.services.core.PersistenceService.java
private void init() { this.lastCommitQueueCheckSum = getQueueModelChecksum(); collectionChanged.put(Urgency.LOW, false); collectionChanged.put(Urgency.MEDIUM, false); collectionChanged.put(Urgency.HIGH, false); setPriority(Thread.MAX_PRIORITY); }
From source file:net.sf.jacclog.service.importer.internal.queue.LogEntryQueuePersisterObserver.java
public LogEntryQueuePersisterObserver(final LogEntryImportService<ReadonlyLogEntry> service) { if (service == null) { throw new IllegalArgumentException("Argument 'service' can not be null."); }/*from ww w.ja va 2 s .com*/ this.service = service; final BasicThreadFactory factory = new BasicThreadFactory.Builder() // attributes .namingPattern("persister-%d").daemon(true).priority(Thread.MAX_PRIORITY) .uncaughtExceptionHandler(new UncaughtExceptionHandler()).build(); executor = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors(), factory); }
From source file:nl.strohalm.cyclos.services.accounts.AccountStatusHandlerImpl.java
public void afterPropertiesSet() throws Exception { thread = new Thread(this, "AccountStatusHandler"); thread.setPriority(Thread.MAX_PRIORITY); thread.start();// w w w . ja v a 2s.c o m }
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./*from w ww .java 2 s . co m*/ */ 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:yoda.threads.ResponderExecutionHandler.java
/** * Return the thread priority./*from w w w .ja v a2 s. c om*/ * * If the property is not there then normal priority will be used. * * @param value * @return the priority * @throws IllegalArgumentException if the value is invalid. * @since 1.0 */ private int parseThreadPriority(String value) { // It has not been set, so set it at 5 if (StringUtils.isBlank(value)) { return Thread.NORM_PRIORITY; } try { int priority = Integer.parseInt(value); if (priority > Thread.MAX_PRIORITY || priority < Thread.MIN_PRIORITY) { throw new IllegalArgumentException(THREAD_PRIORITY_KEY); } return priority; } catch (NumberFormatException numberFormatException) { throw new IllegalArgumentException(THREAD_PRIORITY_KEY); } }