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:org.seasar.mayaa.impl.AutoPageBuilder.java
/** * ??// www . ja v a2s.c o m * Engine???????? * ???autoBuild?false????????? * * contextPath?"/mayaa"???"/"??"/"??? * * @param servletConfig ServletConfig * @param contextPath */ public void init(ServletConfig servletConfig, String contextPath) { Engine engine = ProviderUtil.getEngine(); boolean autoBuild = ObjectUtil.booleanValue(engine.getParameter(OPTION_AUTO_BUILD), false); if (autoBuild && (ParameterAware.IS_SECURE_WEB == false)) { _servletContext = servletConfig.getServletContext(); _contextPath = prepareContextPath(contextPath, engine); _repeat = ObjectUtil.booleanValue(engine.getParameter(OPTION_AUTO_BUILD_REPRAT), REPEAT_DEFAULT); _wait = ObjectUtil.numberValue(engine.getParameter(OPTION_AUTO_BUILD_WAIT), new Integer(WAIT_DEFAULT)) .intValue() * 1000; _renderMate = ObjectUtil.booleanValue(engine.getParameter(OPTION_AUTO_BUILD_RENDER_MATE), RENDER_MATE_DEFAULT); String filters = engine.getParameter(OPTION_AUTO_BUILD_FILE_FILTERS); if (filters != null) { _fileFilters = filters.split(";"); } else { _fileFilters = new String[] { ".html" }; } _thread = new Thread(this) { { setDaemon(true); setName("mayaa.AutoPageBuilder"); setPriority(Thread.MIN_PRIORITY); start(); } }; LOG.info("mayaa.AutoPageBuilder start"); } }
From source file:org.peterbaldwin.vlcremote.sweep.PortSweeper.java
/** * Scans all local IP addresses using a pool of worker threads and waits for * the all of the workers to finish scanning before returning. *//* w w w . j av a 2 s. com*/ private void handleScan(byte[] interfaceAddress) { Worker[] workers = new Worker[mWorkerCount]; for (int i = 0; i < workers.length; i++) { Worker worker = workers[i] = new Worker(mPort, mPath); worker.setPriority(Thread.MIN_PRIORITY); worker.setManager(mWorkerManager); worker.setCallback(mWorkerCallback); } int count = 0; // Scan outwards from the interface IP address for best results // with DHCP servers that allocate addresses sequentially. byte start = interfaceAddress[interfaceAddress.length - 1]; for (int delta = 1; delta < 128; delta++) { for (int sign = -1; sign <= 1; sign += 2) { int b = (256 + start + sign * delta) % 256; if (b != 0) { byte[] ipAddress = interfaceAddress.clone(); ipAddress[ipAddress.length - 1] = (byte) b; mAddressQueue.add(ipAddress); count += 1; } else { // Skip broadcast address } } } mCallbackHandler.obtainMessage(HANDLE_START, 0, count).sendToTarget(); for (int i = 0; i < workers.length; i++) { Worker worker = workers[i]; worker.start(); } try { for (int i = 0; i < workers.length; i++) { Worker worker = workers[i]; worker.join(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } finally { mCallbackHandler.sendEmptyMessage(HANDLE_COMPLETE); } }
From source file:com.tealeaf.NativeShim.java
public void sendXHR(int id, String method, String url, String data, boolean async, String[] requestHeaders) { HashMap<String, String> requestHeadersMap = new HashMap<String, String>(); if (requestHeaders != null) { for (int i = 0; i < requestHeaders.length / 2; i++) { requestHeadersMap.put(requestHeaders[i * 2], requestHeaders[i * 2 + 1]); }/*from ww w . j a va 2s .co m*/ } XMLHttpRequest xhr = new XMLHttpRequest(id, method, url, data, async, requestHeadersMap); if (async) { Thread xhrThread = new Thread(xhr); xhrThread.setPriority(Thread.MIN_PRIORITY + 2); xhrThread.start(); } else { xhr.run(); } }
From source file:org.madsonic.service.MediaScannerService.java
/** * Scans the media library./*from www. java 2 s . c om*/ * The scanning is done asynchronously, i.e., this method returns immediately. */ public synchronized void scanLibrary() { if (isScanning()) { return; } scanning = true; Thread thread = new Thread("MediaLibraryScanner") { @Override public void run() { doScanLibrary(); // //TODO: rework // List<Artist> allArtists = artistDao.getAllArtists(); // LOG.info("## ArtistCount: " + allArtists.size()); // // lastFMService.test(allArtists); playlistService.importPlaylists(); playlistService.updatePlaylistStatistics(); } }; thread.setPriority(Thread.MIN_PRIORITY); thread.start(); }
From source file:com.entertailion.android.slideshow.images.ImageManager.java
/** * Load a new set of search results for the specified area. * //w w w.j a v a 2s. com * @param minLong * The minimum longitude for the search area * @param maxLong * The maximum longitude for the search area * @param minLat * The minimum latitude for the search area * @param maxLat * The minimum latitude for the search area * @throws JSONException * @throws URISyntaxException * @throws IOException */ public void load(String query) throws IOException, URISyntaxException, JSONException { this.query = query; loading = false; if (mPrevThread != null && !mPrevThread.isInterrupted()) { mPrevThread.interrupt(); while (mPrevThread.isAlive()) { Log.d(LOG_TAG, "waiting for previous thread..."); try { Thread.sleep(100); } catch (InterruptedException e) { // ignore } } Log.d(LOG_TAG, "thread dead"); clear(); BitmapAjaxCallback.cancel(); AjaxCallback.cancel(); mPrevThread = null; } else { clear(); } loading = true; error = false; mPrevThread = ImageLoaderFactory.getImageLoader(imageManager, query); mPrevThread.setPriority(Thread.MIN_PRIORITY); mPrevThread.start(); }
From source file:maspack.fileutil.MultiFileTransferMonitor.java
/** * Starts monitoring the files that have been added. *//*from w w w.j a va 2 s . com*/ public void start() { if (this.monitorThread == null || monitorThread.getState() == State.TERMINATED) { this.monitorThread = new Thread(this); this.monitorThread.setDaemon(true); this.monitorThread.setPriority(Thread.MIN_PRIORITY); } try { this.monitorThread.start(); } catch (IllegalThreadStateException e) { this.monitorThread = new Thread(this); this.monitorThread.setDaemon(true); this.monitorThread.setPriority(Thread.MIN_PRIORITY); } }
From source file:yoda.threads.ResponderExecutionHandler.java
/** * Return the thread priority./*from w w w .j a va2s .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); } }
From source file:tvbrowser.extras.reminderplugin.ReminderTimerListener.java
public void timeEvent(ArrayList<ReminderListItem> reminders) { // filter expired items, just for safety ArrayList<ReminderListItem> notExpired = new ArrayList<ReminderListItem>(reminders.size()); for (ReminderListItem item : reminders) { if (!item.getProgramItem().getProgram().isExpired()) { notExpired.add(item);//w ww . j a v a2 s.co m } } reminders = notExpired; if (reminders.isEmpty()) { return; } if ("true".equals(mSettings.getProperty("usesound"))) { ReminderPlugin.playSound(mSettings.getProperty("soundfile")); } if ("true".equals(mSettings.getProperty("usebeep"))) { Toolkit.getDefaultToolkit().beep(); } if ("true".equals(mSettings.getProperty("usemsgbox"))) { // sort reminders by time HashMap<Integer, ArrayList<ReminderListItem>> sortedReminders = new HashMap<Integer, ArrayList<ReminderListItem>>( reminders.size()); for (ReminderListItem reminder : reminders) { int time = reminder.getProgram().getStartTime(); // take all already running programs together because there are no different reminder options for them if (reminder.getProgram().isOnAir() || reminder.getProgram().isExpired()) { time = -1; } ArrayList<ReminderListItem> list = sortedReminders.get(time); if (list == null) { list = new ArrayList<ReminderListItem>(); sortedReminders.put(time, list); } list.add(reminder); } // show reminders at same time in one window for (ArrayList<ReminderListItem> singleTimeReminders : sortedReminders.values()) { new ReminderFrame(mReminderList, singleTimeReminders, getAutoCloseReminderTime(singleTimeReminders)); } } else { for (ReminderListItem reminder : reminders) { mReminderList.removeWithoutChecking(reminder.getProgramItem()); mReminderList.blockProgram(reminder.getProgram()); } } if ("true".equals(mSettings.getProperty("useexec"))) { String fName = mSettings.getProperty("execfile", "").trim(); if (StringUtils.isNotEmpty(fName)) { for (ReminderListItem reminder : reminders) { ParamParser parser = new ParamParser(); String fParam = parser.analyse(mSettings.getProperty("execparam", ""), reminder.getProgram()); try { ExecutionHandler executionHandler = new ExecutionHandler(fParam, fName); executionHandler.execute(); } catch (Exception exc) { String msg = mLocalizer.msg("error.2", "Error executing reminder program!\n({0})", fName, exc); ErrorHandler.handle(msg, exc); } } } else { mLog.warning("Reminder program name is not defined!"); } } // send to receiving plugins ProgramReceiveTarget[] targets = ReminderPlugin.getInstance().getClientPluginsTargets(); ArrayList<Program> programs = new ArrayList<Program>(); for (ReminderListItem reminder : reminders) { programs.add(reminder.getProgram()); } for (ProgramReceiveTarget target : targets) { ProgramReceiveIf plugin = target.getReceifeIfForIdOfTarget(); if (plugin != null && plugin.canReceiveProgramsWithTarget()) { plugin.receivePrograms(programs.toArray(new Program[programs.size()]), target); } } SwingUtilities.invokeLater(new Runnable() { public void run() { new Thread("Update reminder tree") { public void run() { setPriority(Thread.MIN_PRIORITY); ReminderPlugin.getInstance().updateRootNode(true); } }.start(); } }); }
From source file:com.apress.progwt.server.service.impl.SchoolServiceImpl.java
private void incrementSchoolPopularity(final School school) { Thread addTagThread = new Thread() { public void run() { try { schoolDAO.incrementSchoolPopularity(school); } catch (Exception e) { log.error("IncrementSchoolPopularity " + e); }/*w w w.j a v a 2 s . c o m*/ log.info("Increment Complete"); } }; addTagThread.setPriority(Thread.MIN_PRIORITY); addTagThread.start(); }
From source file:com.alibaba.jstorm.daemon.worker.Worker.java
public WorkerShutdown execute() throws Exception { List<AsyncLoopThread> threads = new ArrayList<AsyncLoopThread>(); startDispatchThread();//from w w w .ja v a 2 s. com // create client before create task // so create client connection before create task // refresh connection RefreshConnections refreshConn = makeRefreshConnections(); AsyncLoopThread refreshconn = new AsyncLoopThread(refreshConn, false, Thread.MIN_PRIORITY, true); threads.add(refreshconn); // refresh ZK active status RefreshActive refreshZkActive = new RefreshActive(workerData); AsyncLoopThread refreshzk = new AsyncLoopThread(refreshZkActive, false, Thread.MIN_PRIORITY, true); threads.add(refreshzk); // Sync heartbeat to Apsara Container AsyncLoopThread syncContainerHbThread = SyncContainerHb.mkWorkerInstance(workerData.getStormConf()); if (syncContainerHbThread != null) { threads.add(syncContainerHbThread); } JStormMetricsReporter metricReporter = new JStormMetricsReporter(workerData); metricReporter.init(); workerData.setMetricsReporter(metricReporter); // refresh hearbeat to Local dir RunnableCallback heartbeat_fn = new WorkerHeartbeatRunable(workerData); AsyncLoopThread hb = new AsyncLoopThread(heartbeat_fn, false, null, Thread.NORM_PRIORITY, true); threads.add(hb); // shutdown task callbacks List<TaskShutdownDameon> shutdowntasks = createTasks(); workerData.setShutdownTasks(shutdowntasks); return new WorkerShutdown(workerData, threads); }