List of usage examples for java.lang Thread setName
public final synchronized void setName(String name)
From source file:msearch.filmeSuchen.sender.MediathekSwr.java
@Override public synchronized void addToList() { meldungStart();/*w w w. j ava 2 s . co m*/ //Theman suchen listeThemen.clear(); addToList__(); if (MSConfig.getStop()) { meldungThreadUndFertig(); } else if (listeThemen.size() == 0) { meldungThreadUndFertig(); } else { meldungAddMax(listeThemen.size()); for (int t = 0; t < maxThreadLaufen; ++t) { //new Thread(new ThemaLaden()).start(); Thread th = new Thread(new ThemaLaden()); th.setName(SENDERNAME + t); th.start(); } } }
From source file:msearch.filmeSuchen.sender.MediathekKika.java
@Override void addToList() { meldungStart();//from w w w . j a v a 2s.c o m addToListNormal(); addToListHttp(); addToListKaninchen(); if (MSConfig.getStop()) { meldungThreadUndFertig(); } else if (listeThemen.size() == 0 && listeThemenHttp.size() == 0 && listeThemenKaninchen.size() == 0) { meldungThreadUndFertig(); } else { // dann den Sender aus der alten Liste lschen // URLs laufen nur begrenzte Zeit delSenderInAlterListe(SENDERNAME); listeSort(listeThemen, 1); listeSort(listeThemenHttp, 1); meldungAddMax(listeThemen.size() + listeThemenHttp.size() + listeThemenKaninchen.size()); for (int t = 0; t < maxThreadLaufen; ++t) { //new Thread(new ThemaLaden()).start(); Thread th = new Thread(new ThemaLaden()); th.setName(SENDERNAME + t); th.start(); } } }
From source file:org.apache.hadoop.hbase.ipc.SimpleRpcScheduler.java
private void startHandlers(int handlerCount, final BlockingQueue<CallRunner> callQueue, String threadNamePrefix) { for (int i = 0; i < handlerCount; i++) { Thread t = new Thread(new Runnable() { @Override/*from w ww . j a v a 2 s . c o m*/ public void run() { consumerLoop(callQueue); } }); t.setDaemon(true); t.setName(Strings.nullToEmpty(threadNamePrefix) + "RpcServer.handler=" + i + ",port=" + port); t.start(); handlers.add(t); } }
From source file:org.cloudifysource.utilitydomain.admin.TimedAdmin.java
/** * Creates and starts a thread that monitors the admin object usage - if the object was not used for longer than * the maximum idle time, the object is closed and nullified. *//*from w w w. ja va 2 s . c o m*/ private synchronized void startTimingThread() { // create daemon threads, so the timing thread won't keep the process alive executor = Executors.newSingleThreadExecutor(new ThreadFactory() { @Override public Thread newThread(Runnable runnable) { Thread thread = Executors.defaultThreadFactory().newThread(runnable); thread.setDaemon(true); thread.setName("AdminTimingThread"); return thread; } }); executor.execute(new Runnable() { @Override public void run() { running = true; while (running) { try { if (admin != null && (lastUsed + MAX_IDLE_TIME_MILLIS < System.currentTimeMillis())) { logger.fine("Closing expired admin object"); admin.close(); admin = null; running = false; } Thread.sleep(POLLING_INTERVAL_MILLIS); } catch (final InterruptedException e) { // ignore } } } }); executor.shutdown(); }
From source file:org.openhab.binding.nikobus.internal.NikobusBinding.java
public NikobusBinding() { // setup a command receiver in it's own thread commandReceiver = new NikobusCommandReceiver(this); commandReceiver.setBufferQueue(serialInterface.getBufferQueue()); Thread receiverThread = new Thread(commandReceiver); receiverThread.setName("Nikobus Receiver"); receiverThread.setDaemon(true);/*from www.j a v a2 s . c o m*/ receiverThread.start(); log.debug("Started Command Receiver Thread."); commandSender = new NikobusCommandSender(serialInterface); Thread senderThread = new Thread(commandSender); senderThread.setName("Nikobus Sender"); senderThread.setDaemon(true); senderThread.start(); log.debug("Started Command Sender Thread."); }
From source file:playground.christoph.evacuation.analysis.EvacuationTimeClusterer.java
private void createCostMap() { log.info("Total OD Pairs to Calculate: " + (int) Math.pow(locationMap.size(), 2)); Counter counter = new Counter("Calculated OD Pairs: "); costMap = new ConcurrentHashMap<BasicLocation, Map<BasicLocation, Double>>(); Thread[] threads = new Thread[numOfThreads]; for (int i = 0; i < numOfThreads; i++) { TravelTimeCost travelTimeCost = new TravelTimeCost(); FullNetworkDijkstra leastCostPathCalculator = new FullNetworkDijkstraFactory() .createPathCalculator(network, travelTimeCost, travelTimeCost); Thread thread = new ParallelThread(); thread.setDaemon(true);/*from w w w .j a v a2s . c om*/ thread.setName("ParallelEvacuationTimeClusterThread" + i); ((ParallelThread) thread).network = network; ((ParallelThread) thread).counter = counter; ((ParallelThread) thread).locationMap = locationMap; ((ParallelThread) thread).costMap = costMap; ((ParallelThread) thread).leastCostPathCalculator = leastCostPathCalculator; threads[i] = thread; } int i = 0; for (BasicLocation fromLocation : locationMap.keySet()) { ((ParallelThread) threads[i++ % numOfThreads]).fromLocations.add(fromLocation); } for (Thread thread : threads) { thread.start(); } // wait until each thread is finished try { for (Thread thread : threads) { thread.join(); } } catch (InterruptedException e) { throw new RuntimeException(e); } log.info("done."); }
From source file:net.darkmist.clf.IndexedLogFileHandler.java
protected void nextHandler(File file) { Matcher matcher;// w w w. j a va 2s . c o m String base; String previousThreadName; Thread thread; // get the base name... matcher = getMatcher(); base = matcher.group(1); // check the index for it if (notInIndex(file, base)) return; // pass it on thread = Thread.currentThread(); previousThreadName = thread.getName(); thread.setName("log: " + file); logger.info("scanning"); try { super.nextHandler(file); } finally { thread.setName(previousThreadName); } }
From source file:org.trpr.platform.runtime.impl.bootstrap.spring.Bootstrap.java
/** * Initializes this Bootstrap with the specified config file path * //from w ww.ja v a 2 s. c o m * @param bootstrapConfigFile the runtime bootstrap config file */ public void init(String bootstrapConfigFile) { this.bootstrapConfigFile = bootstrapConfigFile; // store the thread's context class loader for later use by life cycle methods this.tccl = Thread.currentThread().getContextClassLoader(); try { // start the runtime this.start(); // Register this Bootstrap with the platform's MBean server after start() has been called and any app specific JMX name suffix has been loaded new BootstrapModelMBeanExporter().exportBootstrapMBean(this); } catch (Exception e) { // catch all block to consume and minimally log bootstrap errors // Log to both logger and System.out.println(); LOGGER.error("Fatal error in bootstrap sequence. Cannot continue!", e); System.out.println("Fatal error in bootstrap sequence. Cannot continue!"); e.printStackTrace(System.out); return; } if (RuntimeConstants.STANDALONE.equals(RuntimeVariables.getRuntimeNature())) { // Add a shutdown hook Runtime.getRuntime().addShutdownHook(new BootstrapShutdownThread(this)); // Start up the background thread which will keep the JVM alive when #stop() is called on this Bootstrap via a management console/interface Thread backgroundThread = new Thread(this); backgroundThread.setName(RuntimeConstants.BOOTSTRAP_BACKGROUND_THREADNAME); backgroundThread.start(); } }
From source file:mServer.crawler.sender.MediathekSrf.java
@Override public void addToList() { // data-teaser-title="1 gegen 100" // data-teaser-url="/sendungen/1gegen100" final String muster = "{\"id\":\""; MSStringBuilder seite = new MSStringBuilder(Const.STRING_BUFFER_START_BUFFER); listeThemen.clear();/*w w w .j ava 2 s .co m*/ meldungStart(); GetUrl getUrlIo = new GetUrl(getWartenSeiteLaden()); seite = getUrlIo.getUri_Utf(SENDERNAME, SRF_TOPIC_PAGE_URL, seite, ""); int pos = 0; int pos1; String thema, id; while ((pos = seite.indexOf(muster, pos)) != -1) { pos += muster.length(); if ((pos1 = seite.indexOf("\"", pos)) != -1) { id = seite.substring(pos, pos1); if (id.length() < 10) { //{"id":"A","title":"A","contai.... continue; } if (!id.isEmpty()) { thema = seite.extract("\"title\":\"", "\"", pos1); thema = StringEscapeUtils.unescapeJava(thema).trim(); listeThemen.addUrl(new String[] { id, thema }); } } } if (Config.getStop() || listeThemen.isEmpty()) { meldungThreadUndFertig(); } else { meldungAddMax(listeThemen.size()); for (int t = 0; t < getMaxThreadLaufen(); ++t) { Thread th = new ThemaLaden(); th.setName(SENDERNAME + t); th.start(); } } }
From source file:bear.core.SessionContext.java
public void setThread(Thread thread) { this.thread = thread; thread.setName(threadName()); foo(); }