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:im.neon.util.VectorRoomMediasSender.java
/** * Constructor/*from ww w .j ava 2s . c om*/ * @param roomActivity the room activity. */ public VectorRoomMediasSender(VectorRoomActivity roomActivity, VectorMessageListFragment vectorMessageListFragment, MXMediasCache mediasCache) { mVectorRoomActivity = roomActivity; mVectorMessageListFragment = vectorMessageListFragment; mMediasCache = mediasCache; if (null == mHandlerThread) { mHandlerThread = new HandlerThread("VectorRoomMediasSender", Thread.MIN_PRIORITY); mHandlerThread.start(); mMediasSendingHandler = new android.os.Handler(mHandlerThread.getLooper()); } }
From source file:org.hyperic.hq.autoinventory.ScanManager.java
/** * Startup the ScanManager. This fires off a Thread that * manages the scan queue.//from w w w. ja va 2 s. co m */ public synchronized void startup() { shouldExit = false; if (rtScanner != null) { lastRtScan = System.currentTimeMillis(); } mainThread = new Thread() { public void run() { try { mainRunLoop(); } catch (Exception e) { log.error("ERROR in ScanManager thread, exiting: " + e, e); } } }; mainThread.setPriority(Thread.MIN_PRIORITY); mainThread.setDaemon(true); mainThread.setName("autoinventory-scanner"); mainThread.start(); }
From source file:feedsplugin.FeedsPlugin.java
void updateFeeds() { Thread thread = new Thread("Update feeds") { @Override//from w w w. j av a2 s.co m public void run() { updateFeedsInternal(); } }; thread.setPriority(Thread.MIN_PRIORITY); thread.start(); }
From source file:cx.fbn.nevernote.threads.IndexRunner.java
@Override public void run() { thread().setPriority(Thread.MIN_PRIORITY); noteSignal = new NoteSignal(); resourceSignal = new NoteResourceSignal(); signal = new IndexSignal(); logger.log(logger.EXTREME, "Starting index thread "); while (keepRunning) { idle = true;//from ww w .ja v a 2 s .c o m try { conn.commitTransaction(); uncommittedCount = 0; String work = workQueue.take(); idle = false; if (work.startsWith("SCAN")) { guid = null; interrupt = false; indexType = SCAN; } if (work.startsWith("REINDEXALL")) { guid = null; indexType = REINDEXALL; } if (work.startsWith("REINDEXNOTE")) { work = work.replace("REINDEXNOTE ", ""); guid = work; indexType = REINDEXNOTE; } if (work.startsWith("STOP")) { keepRunning = false; guid = null; } logger.log(logger.EXTREME, "Type:" + indexType); if (indexType == SCAN && keepRunning) { logger.log(logger.MEDIUM, "Scanning for unindexed notes & resources"); scanUnindexed(); setIndexType(0); } if (indexType == REINDEXALL && keepRunning) { logger.log(logger.MEDIUM, "Marking all for reindex"); reindexAll(); setIndexType(0); } if (indexType == REINDEXNOTE && keepRunning) { reindexNote(); } } catch (InterruptedException e) { logger.log(logger.LOW, "Thread interrupted exception: " + e.getMessage()); } } logger.log(logger.EXTREME, "Shutting down database"); conn.dbShutdown(); logger.log(logger.EXTREME, "Database shut down. Exiting thread"); }
From source file:com.alibaba.jstorm.daemon.supervisor.Supervisor.java
/** * create and start one supervisor/*ww w . j a va2s. c o m*/ * * @param conf : configurationdefault.yaml storm.yaml * @param sharedContext : null (right now) * @return SupervisorManger: which is used to shutdown all workers and supervisor */ @SuppressWarnings("rawtypes") public SupervisorManger mkSupervisor(Map conf, IContext sharedContext) throws Exception { LOG.info("Starting Supervisor with conf " + conf); /** * Step 1: cleanup all files in /storm-local-dir/supervisor/tmp */ String path = StormConfig.supervisorTmpDir(conf); FileUtils.cleanDirectory(new File(path)); /* * Step 2: create ZK operation instance StromClusterState */ StormClusterState stormClusterState = Cluster.mk_storm_cluster_state(conf); String hostName = JStormServerUtils.getHostName(conf); WorkerReportError workerReportError = new WorkerReportError(stormClusterState, hostName); /* * Step 3, create LocalStat LocalStat is one KV database 4.1 create LocalState instance; 4.2 get supervisorId, if no supervisorId, create one */ LocalState localState = StormConfig.supervisorState(conf); String supervisorId = (String) localState.get(Common.LS_ID); if (supervisorId == null) { supervisorId = UUID.randomUUID().toString(); localState.put(Common.LS_ID, supervisorId); } Vector<AsyncLoopThread> threads = new Vector<AsyncLoopThread>(); // Step 5 create HeartBeat // every supervisor.heartbeat.frequency.secs, write SupervisorInfo to ZK // sync hearbeat to nimbus Heartbeat hb = new Heartbeat(conf, stormClusterState, supervisorId); hb.update(); AsyncLoopThread heartbeat = new AsyncLoopThread(hb, false, null, Thread.MIN_PRIORITY, true); threads.add(heartbeat); // Sync heartbeat to Apsara Container AsyncLoopThread syncContainerHbThread = SyncContainerHb.mkSupervisorInstance(conf); if (syncContainerHbThread != null) { threads.add(syncContainerHbThread); } // Step 6 create and start sync Supervisor thread // every supervisor.monitor.frequency.secs second run SyncSupervisor EventManagerImp processEventManager = new EventManagerImp(); AsyncLoopThread processEventThread = new AsyncLoopThread(processEventManager); threads.add(processEventThread); ConcurrentHashMap<String, String> workerThreadPids = new ConcurrentHashMap<String, String>(); SyncProcessEvent syncProcessEvent = new SyncProcessEvent(supervisorId, conf, localState, workerThreadPids, sharedContext, workerReportError); EventManagerImp syncSupEventManager = new EventManagerImp(); AsyncLoopThread syncSupEventThread = new AsyncLoopThread(syncSupEventManager); threads.add(syncSupEventThread); SyncSupervisorEvent syncSupervisorEvent = new SyncSupervisorEvent(supervisorId, conf, processEventManager, syncSupEventManager, stormClusterState, localState, syncProcessEvent, hb); int syncFrequence = JStormUtils.parseInt(conf.get(Config.SUPERVISOR_MONITOR_FREQUENCY_SECS)); EventManagerPusher syncSupervisorPusher = new EventManagerPusher(syncSupEventManager, syncSupervisorEvent, syncFrequence); AsyncLoopThread syncSupervisorThread = new AsyncLoopThread(syncSupervisorPusher); threads.add(syncSupervisorThread); Httpserver httpserver = null; if (StormConfig.local_mode(conf) == false) { // Step 7 start httpserver int port = ConfigExtension.getSupervisorDeamonHttpserverPort(conf); httpserver = new Httpserver(port, conf); httpserver.start(); } // SupervisorManger which can shutdown all supervisor and workers return new SupervisorManger(conf, supervisorId, threads, syncSupEventManager, processEventManager, httpserver, stormClusterState, workerThreadPids); }
From source file:org.dawnsci.commandserver.core.producer.AliveConsumer.java
protected void startNotifications() throws Exception { if (uri == null) throw new NullPointerException("Please set the URI before starting notifications!"); this.cbean = new ConsumerBean(); cbean.setStatus(ConsumerStatus.STARTING); cbean.setName(getName());/*from w w w . j a v a2 s .c o m*/ cbean.setConsumerId(consumerId); cbean.setVersion(consumerVersion); cbean.setStartTime(System.currentTimeMillis()); try { cbean.setHostName(InetAddress.getLocalHost().getHostName()); } catch (UnknownHostException e) { // Not fatal but would be nice... e.printStackTrace(); } System.out.println("Running events on topic " + Constants.ALIVE_TOPIC + " to notify of '" + getName() + "' service being available."); final Thread aliveThread = new Thread(new Runnable() { public void run() { try { ConnectionFactory connectionFactory = ConnectionFactoryFacade.createConnectionFactory(uri); aliveConnection = connectionFactory.createConnection(); aliveConnection.start(); final Session session = aliveConnection.createSession(false, Session.AUTO_ACKNOWLEDGE); final Topic topic = session.createTopic(Constants.ALIVE_TOPIC); final MessageProducer producer = session.createProducer(topic); final ObjectMapper mapper = new ObjectMapper(); // Here we are sending the message out to the topic while (isActive()) { try { Thread.sleep(Constants.NOTIFICATION_FREQUENCY); TextMessage temp = session.createTextMessage(mapper.writeValueAsString(cbean)); producer.send(temp, DeliveryMode.NON_PERSISTENT, 1, 5000); if (ConsumerStatus.STARTING.equals(cbean.getStatus())) { cbean.setStatus(ConsumerStatus.RUNNING); } } catch (InterruptedException ne) { break; } catch (Exception neOther) { neOther.printStackTrace(); } } } catch (Exception ne) { ne.printStackTrace(); setActive(false); } } }); aliveThread.setName("Alive Notification Topic"); aliveThread.setDaemon(true); aliveThread.setPriority(Thread.MIN_PRIORITY); aliveThread.start(); }
From source file:net.sourceforge.subsonic.service.SearchService.java
/** * Generates the search index. If the index already exists it will be * overwritten. The index is created asynchronously, i.e., this method returns * before the index is created./*from w ww . java2 s . c o m*/ */ public synchronized void createIndex() { if (isIndexBeingCreated()) { return; } creatingIndex = true; Thread thread = new Thread("Search Index Generator") { @Override public void run() { doCreateIndex(); } }; thread.setPriority(Thread.MIN_PRIORITY); thread.start(); }
From source file:net.yacy.http.ProxyHandler.java
private void storeToCache(final Response yacyResponse, final byte[] cacheArray) { final Thread t = new Thread() { @Override/* w w w.j a v a2 s.c om*/ public void run() { if (yacyResponse == null) return; this.setName("ProxyHandler.storeToCache(" + yacyResponse.url().toNormalform(true) + ")"); // the cache does either not exist or is (supposed to be) stale deleteFromCache(yacyResponse.url().hash()); if (cacheArray == null || cacheArray.length <= 0) return; yacyResponse.setContent(cacheArray); try { Cache.store(yacyResponse.url(), yacyResponse.getResponseHeader(), cacheArray); sb.toIndexer(yacyResponse); } catch (IOException e) { //log.logWarning("cannot write " + response.url() + " to Cache (1): " + e.getMessage(), e); } } }; t.setPriority(Thread.MIN_PRIORITY); t.start(); }
From source file:net.sourceforge.subsonic.service.MediaScannerService.java
/** * Scans the media library./*from ww w .ja v a2 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(); } }; thread.setPriority(Thread.MIN_PRIORITY); thread.start(); }
From source file:com.searchcode.app.jobs.repository.IndexBaseRepoJob.java
/** * The main method used for finding jobs to index and actually doing the work */// w w w . j av a 2 s . c o m public void execute(JobExecutionContext context) throws JobExecutionException { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); JobDataMap jobDataMap = context.getJobDetail().getJobDataMap(); this.LOWMEMORY = Boolean.parseBoolean(jobDataMap.get("LOWMEMORY").toString()); String repoLocations = jobDataMap.get("REPOLOCATIONS").toString(); if (!isEnabled() || !this.sharedService.getBackgroundJobsEnabled()) { return; } if (this.codeIndexer.shouldPauseAdding()) { Singleton.getLogger().info("Pausing parser."); return; } // Pull the next repo to index from the queue RepoResult repoResult = this.getNextQueuedRepo().poll(); if (repoResult != null && Singleton.getRunningIndexRepoJobs().containsKey(repoResult.getName()) == false) { this.haveRepoResult = true; Singleton.getLogger().info("Indexing " + repoResult.getName()); repoResult.getData().indexStatus = "indexing"; repoResult.getData().jobRunTime = Instant.now(); Singleton.getRepo().saveRepo(repoResult); try { Singleton.getRunningIndexRepoJobs().put(repoResult.getName(), new RunningIndexJob("Indexing", Singleton.getHelpers().getCurrentTimeSeconds())); this.checkCloneSuccess(repoResult.getName(), repoLocations); String repoGitLocation = repoLocations + "/" + repoResult.getName() + "/.git/"; File file = new File(repoGitLocation); boolean existingRepo = file.exists(); boolean useCredentials = repoResult.getUsername() != null && !repoResult.getUsername().isEmpty(); RepositoryChanged repositoryChanged; if (existingRepo) { repositoryChanged = this.updateExistingRepository(repoResult.getName(), repoResult.getUrl(), repoResult.getUsername(), repoResult.getPassword(), repoLocations, repoResult.getBranch(), useCredentials); } else { repositoryChanged = this.getNewRepository(repoResult.getName(), repoResult.getUrl(), repoResult.getUsername(), repoResult.getPassword(), repoLocations, repoResult.getBranch(), useCredentials); } // Write file indicating we have sucessfully cloned this.createCloneUpdateSuccess(repoLocations + "/" + repoResult.getName()); this.triggerIndex(repoResult, repoResult.getName(), repoResult.getUrl(), repoLocations, repoGitLocation, existingRepo, repositoryChanged); } finally { // Clean up the job Singleton.getRunningIndexRepoJobs().remove(repoResult.getName()); } } }