List of usage examples for java.lang Thread setDaemon
public final void setDaemon(boolean on)
From source file:com.nesscomputing.syslog4j.server.SyslogServer.java
public static final SyslogServerIF getThreadedInstance(String protocol) throws SyslogRuntimeException { SyslogServerIF server = getInstance(protocol); if (server.getThread() == null) { Thread thread = new Thread(server); thread.setName("SyslogServer: " + protocol); thread.setDaemon(server.getConfig().isUseDaemonThread()); if (server.getConfig().getThreadPriority() > -1) { thread.setPriority(server.getConfig().getThreadPriority()); }//from w w w .ja va 2 s . c om server.setThread(thread); thread.start(); } return server; }
From source file:io.trivium.Central.java
public static void start() { //register activities Registry.INSTANCE.reload();//from w w w .j a v a2 s. co m try { //init ui handler Binding b = Registry.INSTANCE.getBinding(TypeRef.getInstance(WebUI.class.getCanonicalName())); b.startBinding(); //init web object handler b = Registry.INSTANCE.getBinding(TypeRef.getInstance(WebObjectHandler.class.getCanonicalName())); b.startBinding(); } catch (Exception ex) { logger.log(Level.SEVERE, "error initializing the builtin http handler", ex); } //start anystore server Thread td = new Thread(AnyServer.INSTANCE, "anystore"); td.setDaemon(true); td.start(); // init profiler Timer t = new Timer(); //one second after next time frame starts long start = TimeUtils.getTimeFrameStart(new Date().getTime() + 60000); t.schedule(Profiler.INSTANCE, new Date(start), 60000); logger.log(Level.INFO, "trivium is now running and accessible through the web interface on http://localhost:12345/ui/"); }
From source file:io.dropwizard.websockets.DropWizardWebsocketsTest.java
@BeforeClass public static void setUpClass() throws InterruptedException, IOException { CountDownLatch serverStarted = new CountDownLatch(1); Thread serverThread = new Thread(GeneralUtils.rethrow(() -> new MyApp(serverStarted) .run(new String[] { "server", Resources.getResource("server.yml").getPath() }))); serverThread.setDaemon(true);// w w w . ja v a 2 s .co m serverThread.start(); serverStarted.await(10, SECONDS); }
From source file:com.ariatemplates.attester.junit.StreamRedirector.java
public static void redirectStream(final InputStream inputStream, final OutputStream outputStream) { Thread thread = new Thread(new Runnable() { public void run() { try { IOUtils.copy(inputStream, outputStream); } catch (IOException e) { e.printStackTrace();//from ww w . j a v a2s .c om } } }); thread.setDaemon(false); thread.start(); }
From source file:immf.growl.GrowlNotifier.java
public static GrowlNotifier getInstance(GrowlApiClient clientConcrete, Config config) { if (clientConcrete != null && config != null) { GrowlNotifier notify = new GrowlNotifier(); notify.client = clientConcrete;/* w ww . jav a 2 s . co m*/ notify.config = config; String apiKey = clientConcrete.getApiKeyFromConfig(config); if (apiKey != null && apiKey != "") { String[] apiKeyArray = apiKey.split(","); for (String key : apiKeyArray) { notify.growlApiKeyList.add(new GrowlKey(key)); } if (notify.growlApiKeyList.size() > 0) { notify.client = clientConcrete; Thread t = new Thread(notify); t.setName(notify.client.getClass().getName()); t.setDaemon(true); t.start(); } } return notify; } else { return null; } }
From source file:co.paralleluniverse.fibers.retrofit.FiberRestAdapterBuilderTest.java
@BeforeClass public static void setUpClass() throws InterruptedException, IOException { Thread t = new Thread(new Runnable() { @Override/*w ww.jav a 2s . co m*/ public void run() { try { new HelloWorldApplication().run(new String[] { "server" }); } catch (Exception ex) { } } }); t.setDaemon(true); t.start(); waitUrlAvailable("http://localhost:8080"); }
From source file:com.offbynull.voip.ui.UiWebRegion.java
public static UiWebRegion create(Bus busFromGateway, Bus busToGateway) { UiWebRegion ret = new UiWebRegion(busFromGateway, busToGateway); URL resource = ret.getClass().getResource("/index.html"); Validate.validState(resource != null); // should never happen, sanity check String mainPageLink = resource.toExternalForm(); ret.webEngine.getLoadWorker().stateProperty().addListener((ov, oldState, newState) -> { if (newState == State.SUCCEEDED) { JSObject win = (JSObject) ret.webEngine.executeScript("window"); win.setMember("messageSender", ret.new JavascriptToGatewayBridge()); busToGateway.add(new UiAction(new ReadyAction(false))); } else if (newState == State.CANCELLED || newState == State.FAILED) { busToGateway.add(new UiAction(new ReadyAction(true))); }/*from ww w.j a v a 2 s. co m*/ }); ret.webEngine.load(mainPageLink); // This block makes sure to kill the incoming message pump if this webregion is removed from its parent, and (re)starts it if its // added // // NOTE: CANNOT USE PARENTPROPERTY -- PARENTPROPERTY ALWAYS RETURNS NULL FOR WHATEVER REASON ret.sceneProperty().addListener((observable, oldValue, newValue) -> { ret.lock.lock(); try { if (oldValue != null) { ret.incomingMessagePumpThread.interrupt(); ret.incomingMessagePumpThread.join(); ret.incomingMessagePumpThread = null; } if (newValue != null) { Thread thread = new Thread(ret.new GatewayToJavascriptPump()); thread.setDaemon(true); thread.setName(UiWebRegion.class.getSimpleName() + "-GatewayToJavascriptPump"); thread.start(); ret.incomingMessagePumpThread = thread; } } catch (InterruptedException ex) { throw new IllegalStateException(ex); } finally { ret.lock.unlock(); } }); return ret; }
From source file:mitm.common.net.HTTPMethodExecutorTest.java
private static void startServer() { server = new SimpleSocketServer(SERVER_PORT); Thread serverThread = new Thread(server); serverThread.setDaemon(true); serverThread.start();//w w w . j a v a 2 s . c o m while (!server.isRunning()) { try { Thread.sleep(100); } catch (InterruptedException e) { // ignore } } }
From source file:com.dotmarketing.servlets.taillog.Tailer.java
/** * Creates and starts a Tailer for the given file. * //from w w w . j a va 2 s .c o m * @param file the file to follow. * @param listener the TailerListener to use. * @param delay the delay between checks of the file for new content in milliseconds. * @param end Set to true to tail from the end of the file, false to tail from the beginning of the file. * @return The new tailer */ public static Tailer create(File file, TailerListener listener, long delay, boolean end) { Tailer tailer = new Tailer(file, listener, delay, end); Thread thread = new Thread(tailer); thread.setDaemon(true); thread.start(); return tailer; }
From source file:end2endtests.runner.ProcessRunner.java
private static void redirectStream(final InputStream in, final OutputStream out) { Thread t = new Thread(new Runnable() { public void run() { try { IOUtils.copy(in, out);// ww w . j a va 2 s.c o m } catch (IOException e) { e.printStackTrace(); } finally { IOUtils.closeQuietly(out); } } }); t.setDaemon(true); t.start(); }