List of usage examples for java.lang Thread setName
public final synchronized void setName(String name)
From source file:fusejext2.JextThreadFactory.java
@Override public synchronized Thread newThread(Runnable r) { final String name = new StringBuilder().append(threadPrefix).append("[").append(count.getAndIncrement()) .append("]").toString(); Thread t = new Thread(r); t.setName(name); t.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { @Override/*from w ww . j av a 2 s .c om*/ public void uncaughtException(Thread t, Throwable e) { logger.severe(new StringBuffer().append("Uncaught Exception in thread ").append(name).append("\n") .append(ExceptionUtils.getMessage(e)).append(", ") .append(ExceptionUtils.getRootCauseMessage(e)).append("\n") .append(ExceptionUtils.getFullStackTrace(e)).toString()); logger.severe("Shutting down due to unexpected exception.."); System.exit(23); } }); logger.info("Created new Thread: " + name); return t; }
From source file:com.espertech.esper.epl.metric.MetricsExecutorThreaded.java
/** * Ctor.// w ww. ja v a 2 s . co m * @param engineURI engine URI */ public MetricsExecutorThreaded(final String engineURI) { ThreadFactory threadFactory = new ThreadFactory() { AtomicInteger count = new AtomicInteger(0); public Thread newThread(Runnable r) { String uri = engineURI; if (engineURI == null) { uri = "default"; } Thread t = new Thread(r); t.setName("com.espertech.esper.MetricReporting-" + uri + "-" + count.getAndIncrement()); t.setDaemon(true); return t; } }; threadPool = Executors.newCachedThreadPool(threadFactory); }
From source file:org.wso2.andes.messageStore.MessageContentRemoverTask.java
public void start() { this.setRunning(true); Thread t = new Thread(this); t.setName(this.getClass().getSimpleName() + "-Thread"); t.start();// w w w .j a va 2s .c om }
From source file:heigit.ors.servlet.listeners.ORSInitContextListener.java
public void contextInitialized(ServletContextEvent contextEvent) { Runnable runnable = () -> { try {//www .j a va 2 s . co m RoutingProfileManager.getInstance().toString(); } catch (Exception e) { LOGGER.warn("Unable to initialize ORS."); e.printStackTrace(); } }; Thread thread = new Thread(runnable); thread.setName("ORS-Init"); thread.start(); }
From source file:com.adaptris.hpcc.ManagedPumpStreamHandler.java
protected Thread createPump(final InputStream is, final OutputStream os, final boolean closeWhenExhausted) { String name = Thread.currentThread().getName(); final Thread result = MTF.newThread(new StreamPumper(is, os, closeWhenExhausted)); result.setName(name); result.setDaemon(true);/*from w w w.j a va 2 s.c om*/ return result; }
From source file:org.apache.synapse.commons.throttle.core.ThrottleContextCleanupTask.java
public ThrottleContextCleanupTask() { ScheduledExecutorService executor = Executors.newScheduledThreadPool(1, new ThreadFactory() { public Thread newThread(Runnable r) { Thread t = new Thread(r); t.setName("Throttle Cleanup Task"); return t; }/*from ww w. ja v a2s . c o m*/ }); String throttleFrequency = System.getProperty(THROTTLE_CONTEXT_CLEANUP_TASK_FREQUENCY); if (throttleFrequency == null) { throttleFrequency = "3600000"; } if (log.isDebugEnabled()) { log.debug("Throttling Cleanup Task Frequency set to " + throttleFrequency); } executor.scheduleAtFixedRate(new CleanupTask(), Integer.parseInt(throttleFrequency), Integer.parseInt(throttleFrequency), TimeUnit.MILLISECONDS); }
From source file:org.bhave.experiment.data.TestKafkaConsumer.java
@Test public void testConfigureKafkaConsumer() throws InterruptedException { KafkaDataConsumer consumer = new KafkaDataConsumer(); Configuration config = new PropertiesConfiguration(); config.addProperty(KafkaDataConsumer.HOST_CFG, "localhost"); config.addProperty(KafkaDataConsumer.PORT_CFG, KafkaDataConsumer.DEFAULT_PORT_CFG); config.addProperty(KafkaDataConsumer.TOPIC_CFG, "test"); config.addProperty(KafkaDataConsumer.P_PRODUCER_ID, 0); consumer.loadConfiguration(config);/*from ww w. j a v a2s . c o m*/ Configuration configuration = consumer.getConfiguration(); assertNotNull(configuration); consumer.addExporter(new StdOutDataExporter()); Thread consumerThread = new Thread(consumer); consumerThread.setName("Consumer Thread"); consumerThread.start(); assertTrue(consumerThread.isAlive()); //this should terminate the thread in which it is running consumer.finish(); Thread.sleep(1000); assertFalse(consumerThread.isAlive()); System.out.println("Kafka Consumer Thread terminated"); }
From source file:org.shredzone.cilla.core.search.IndexerServiceImpl.java
@Override public void reindex() { synchronized (this) { if (running) { return; }//from w w w. j a v a 2 s. c o m running = true; } Thread th = new Thread(this); th.setName("Indexer Thread"); th.start(); }
From source file:immf.ForwardMailPicker.java
public ForwardMailPicker(Config conf, ServerMain server) { this.conf = conf; this.server = server; int id = conf.getConfigId(); if (true) {//www . ja v a2s .c o m Thread t = new Thread(this); t.setName("ForwardMailPicker[" + id + "]"); t.setDaemon(true); t.start(); } }
From source file:org.cc86.MMC.server.Main.java
private void bootstrap() { setupLibraries();/*w w w . j a v a2 s . com*/ Thread discovery = new Thread(Discovery.getInstance()); discovery.setName("DISCOVERY"); discovery.start(); mgr = new PluginManager(); dispatcher = new Dispatcher(mgr); core = new ServerCore(0xCC86); mgr.loadPlugins(); Thread t = new Thread(() -> core.bootUp()); t.setName("TCP listener"); t.start(); }