List of usage examples for java.lang Thread setName
public final synchronized void setName(String name)
From source file:mServer.crawler.sender.MediathekBr.java
private void startCrawlerThreads() { for (int t = 0; t <= getMaxThreadLaufen(); ++t) { Thread th = new ThemaLaden(); th.setName(SENDERNAME + t); th.start();/*from w w w.jav a 2s .com*/ } }
From source file:mServer.crawler.sender.MediathekBr.java
private void startKlassikThread() { Thread thKlassik = new KlassikLaden(); thKlassik.setName(SENDERNAME + "-Klassik"); thKlassik.start();/*from w w w . j a v a2 s .com*/ }
From source file:net.dv8tion.jda.entities.impl.PrivateChannelImpl.java
@Override public void sendFileAsync(File file, Message message, Consumer<Message> callback) { Thread thread = new Thread(() -> { Message messageReturn;/*www. j a v a 2 s . c o m*/ try { messageReturn = sendFile(file, message); } catch (RateLimitedException e) { JDAImpl.LOG.warn("Got ratelimited when trying to upload file. Providing null to callback."); messageReturn = null; } if (callback != null) callback.accept(messageReturn); }); thread.setName("PrivateChannelImpl SendFileAsync Channel: " + id); thread.setDaemon(true); thread.start(); }
From source file:org.cloudata.core.common.ipc.CClient.java
/** * Construct an IPC client whose values are of the given {@link CWritable} * class.//from w ww .j a va2s . c o m */ public CClient(Class valueClass, CloudataConf conf, SocketFactory factory) { this.valueClass = valueClass; this.timeout = conf.getInt("ipc.client.timeout", 10000); this.maxIdleTime = conf.getInt("ipc.client.connection.maxidletime", 1000); this.maxRetries = conf.getInt("ipc.client.connect.max.retries", 10); this.conf = conf; this.socketFactory = factory; Thread t = new ConnectionCuller(); t.setDaemon(true); t.setName(valueClass.getName() + " Connection Culler"); LOG.debug(valueClass.getName() + "Connection culler maxidletime= " + maxIdleTime + "ms"); t.start(); }
From source file:com.baifendian.swordfish.execserver.runner.flow.FlowRunnerManager.java
public FlowRunnerManager(Configuration conf) { this.flowDao = DaoFactory.getDaoInstance(FlowDao.class); int flowThreads = conf.getInt(Constants.EXECUTOR_FLOWRUNNER_THREADS, Constants.defaultFlowRunnerThreadNum); ThreadFactory flowThreadFactory = new ThreadFactoryBuilder().setNameFormat("Exec-Worker-FlowRunner") .build();//from ww w . ja va2s.c o m flowExecutorService = Executors.newFixedThreadPool(flowThreads, flowThreadFactory); int nodeThreads = conf.getInt(Constants.EXECUTOR_NODERUNNER_THREADS, Constants.defaultNodeRunnerThreadNum); ThreadFactory nodeThreadFactory = new ThreadFactoryBuilder().setNameFormat("Exec-Worker-NodeRunner") .build(); nodeExecutorService = Executors.newFixedThreadPool(nodeThreads, nodeThreadFactory); // ?? runningFlows ?? Thread cleanThread = new Thread(() -> { while (true) { try { cleanFinishedFlows(); } catch (Exception e) { logger.error("clean thread error ", e); } finally { try { Thread.sleep(Constants.defaultCleanFinishFlowInterval); } catch (InterruptedException e) { } } } }); cleanThread.setDaemon(true); cleanThread.setName("finishedFlowClean"); cleanThread.start(); }
From source file:cc.arduino.Compiler.java
private void exec(String[] command) throws RunnerException { // eliminate any empty array entries List<String> stringList = new ArrayList<>(); for (String string : command) { string = string.trim();/* w w w . ja v a2 s. c o m*/ if (string.length() != 0) stringList.add(string); } command = stringList.toArray(new String[stringList.size()]); if (command.length == 0) return; if (verbose) { for (String c : command) System.out.print(c + " "); System.out.println(); } DefaultExecutor executor = new DefaultExecutor(); executor.setStreamHandler(new PumpStreamHandler() { @Override protected Thread createPump(InputStream is, OutputStream os, boolean closeWhenExhausted) { final Thread result = new Thread(new MyStreamPumper(is, Compiler.this)); result.setName("MyStreamPumper Thread"); result.setDaemon(true); return result; } }); CommandLine commandLine = new DoubleQuotedArgumentsOnWindowsCommandLine(command[0]); for (int i = 1; i < command.length; i++) { commandLine.addArgument(command[i], false); } int result; executor.setExitValues(null); try { result = executor.execute(commandLine); } catch (IOException e) { RunnerException re = new RunnerException(e.getMessage()); re.hideStackTrace(); throw re; } executor.setExitValues(new int[0]); // an error was queued up by message(), barf this back to compile(), // which will barf it back to Editor. if you're having trouble // discerning the imagery, consider how cows regurgitate their food // to digest it, and the fact that they have five stomaches. // //System.out.println("throwing up " + exception); if (exception != null) throw exception; if (result > 1) { // a failure in the tool (e.g. unable to locate a sub-executable) System.err.println(I18n.format(tr("{0} returned {1}"), command[0], result)); } if (result != 0) { RunnerException re = new RunnerException(tr("Error compiling.")); re.hideStackTrace(); throw re; } }
From source file:msearch.filmeSuchen.sender.MediathekBr.java
@Override void addToList() { if (MSConfig.senderAllesLaden) { maxThreadLaufen = 8;/*www . j a v a 2 s . c o m*/ } meldungStart(); getTheman(); // Themen suchen getTage(); // Programm der letzten Tage absuchen if (MSConfig.getStop()) { meldungThreadUndFertig(); } else if (listeThemen.isEmpty() && listeTage.isEmpty()) { meldungThreadUndFertig(); } else { meldungAddMax(listeThemen.size() + listeTage.size()); // erst hier starten (Archiv, Klassik), sonst beendet er sich/und sucht doch! if (MSConfig.senderAllesLaden) { // Archiv durchsuchen Thread thArchiv; thArchiv = new Thread(new ArchivLaden(1, 100)); thArchiv.setName(SENDERNAME); thArchiv.start(); thArchiv = new Thread(new ArchivLaden(101, 200)); thArchiv.setName(SENDERNAME); thArchiv.start(); thArchiv = new Thread(new ArchivLaden(201, 300)); thArchiv.setName(SENDERNAME); thArchiv.start(); thArchiv = new Thread(new ArchivLaden(301, 400)); thArchiv.setName(SENDERNAME); thArchiv.start(); } new Thread(new KlassikLaden(), SENDERNAME).start(); // Klassik braucht auch eine Einzelbehandlung for (int t = 0; t < maxThreadLaufen; ++t) { Thread th = new Thread(new ThemaLaden()); th.setName(SENDERNAME + t); th.start(); } } }
From source file:org.apache.cocoon.components.store.impl.StoreJanitorImpl.java
private void doStart() throws Exception { this.doRun = true; Thread checker = new Thread(this); if (getLogger().isDebugEnabled()) { getLogger().debug("Intializing checker thread"); }//from ww w .ja v a 2 s . com checker.setPriority(getPriority()); checker.setDaemon(true); checker.setName("checker"); checker.start(); }
From source file:org.apache.hadoop.hdfs.server.namenode.ha.TestHASafeMode.java
/** * Make sure the client retries when the active NN is in safemode *///from w w w. ja v a 2 s . co m @Test(timeout = 300000) public void testClientRetrySafeMode() throws Exception { final Map<Path, Boolean> results = Collections.synchronizedMap(new HashMap<Path, Boolean>()); final Path test = new Path("/test"); // let nn0 enter safemode NameNodeAdapter.enterSafeMode(nn0, false); NameNodeAdapter.enterSafeMode(nn1, false); SafeModeInfo safeMode = nn0.getNamesystem().getSafeModeInfoForTests(); Whitebox.setInternalState(safeMode, "extension", Integer.valueOf(30000)); HdfsVariables.setSafeModeInfo(safeMode, safeMode.getReached()); LOG.info("enter safemode"); Thread testThread = new Thread() { @Override public void run() { try { boolean mkdir = fs.mkdirs(test); LOG.info("mkdir finished, result is " + mkdir); synchronized (TestHASafeMode.this) { results.put(test, mkdir); TestHASafeMode.this.notifyAll(); } } catch (Exception e) { LOG.info("Got Exception while calling mkdir", e); } } }; testThread.setName("test"); testThread.start(); // make sure the client's call has actually been handled by the active NN assertFalse("The directory should not be created while NN in safemode", fs.exists(test)); Thread.sleep(1000); // let nn0 leave safemode NameNodeAdapter.leaveSafeMode(nn0); LOG.info("leave safemode"); synchronized (this) { while (!results.containsKey(test)) { this.wait(); } assertTrue(results.get(test)); } }
From source file:io.warp10.quasar.trl.QuasarTokenRevocationListLoader.java
public void init() { // initialize only once per JVM if (initialized.get()) { return;//ww w .j a v a2 s .c om } Thread t = new Thread() { @Override public void run() { while (true) { loadTrl(); // time to sleep try { Thread.sleep(delay); } catch (InterruptedException ie) { } } // while(true) } // run() }; if (null != path && initialized.compareAndSet(false, true)) { t.setName("[TokenRevocationListLoader]"); t.setDaemon(true); t.start(); } }