List of usage examples for java.lang Thread setDaemon
public final void setDaemon(boolean on)
From source file:by.zuyeu.deyestracker.reader.ui.readpane.ReadPaneController.java
private void addScrollTracker() throws DEyesTrackerException { LOG.info("addScrollTracker() - start;"); if (!scrollExist) { application.getStage().addEventFilter(KeyEvent.KEY_PRESSED, (KeyEvent evt) -> { if (evt.getCode().equals(KeyCode.DOWN)) { Platform.runLater(() -> { LOG.debug("down - vvalue = {}", spText.getVvalue()); spText.setVvalue(spText.getVvalue() + spText.getVmax() / 10); });//from w w w .j a v a2 s. c o m } if (evt.getCode().equals(KeyCode.UP)) { Platform.runLater(() -> { LOG.debug("up - vvalue = {}", spText.getVvalue()); spText.setVvalue(spText.getVvalue() - spText.getVmax() / 10); }); } }); final Thread t = new Thread() { @Override public void run() { runEyeTracker(); } }; t.setDaemon(true); t.start(); scrollExist = true; } LOG.info("addScrollTracker() - end;"); }
From source file:com.nesscomputing.event.amqp.AmqpEventReceiver.java
@OnStage(LifecycleStage.START) void start() {/*from w w w . ja v a 2 s .c o m*/ final ExchangeConsumer exchangeConsumer = exchangeConsumerHolder.get(); if (exchangeConsumer != null) { Preconditions.checkState(consumerThreadHolder.get() == null, "already started, boldly refusing to start twice!"); final Thread consumerThread = new Thread(exchangeConsumer, "ness-event-amqp-consumer"); Preconditions.checkState(consumerThreadHolder.getAndSet(consumerThread) == null, "thread already set, this should not happen!"); consumerThread.setDaemon(true); consumerThread.start(); } else { LOG.debug("AMQP seems to be disabled, skipping Event receiver start!"); } }
From source file:net.sbbi.upnp.jmx.UPNPMBeanDevicesRequestsHandler.java
protected void addUPNPMBeanDevice(UPNPMBeanDevice rootDevice) { synchronized (handledDevices) { for (Iterator i = handledDevices.iterator(); i.hasNext();) { UPNPMBeanDevice registred = (UPNPMBeanDevice) i.next(); if (registred.getDeviceType().equals(rootDevice.getDeviceType()) && registred.getUuid().equals(rootDevice.getUuid())) { // API Use error throw new RuntimeException("An UPNPMBeanDevice object of type " + rootDevice.getDeviceType() + " with uuid " + rootDevice.getUuid() + " is already registred within this class, use a different UPNPMBeanDevice internalId"); }// w w w.ja v a 2 s .c o m } if (handledDevices.size() == 0) { Thread runner = new Thread(this, "UPNPMBeanDevicesRequestsHandler " + bindAddress.toString()); runner.setDaemon(true); runner.start(); } handledDevices.add(rootDevice); // adding the child devices for (Iterator i = rootDevice.getUPNPMBeanChildrens().iterator(); i.hasNext();) { handledDevices.add(i.next()); } } }
From source file:org.apache.asterix.experiment.client.SpatialQueryGenerator.java
public SpatialQueryGenerator(SpatialQueryGeneratorConfig config) { threadPool = Executors.newCachedThreadPool(new ThreadFactory() { private final AtomicInteger count = new AtomicInteger(); @Override/* w ww . j a va 2 s . c om*/ public Thread newThread(Runnable r) { int tid = count.getAndIncrement(); Thread t = new Thread(r, "DataGeneratorThread: " + tid); t.setDaemon(true); return t; } }); partitionRangeStart = config.getPartitionRangeStart(); duration = config.getDuration(); restHost = config.getRESTHost(); restPort = config.getRESTPort(); orchHost = config.getQueryOrchestratorHost(); orchPort = config.getQueryOrchestratorPort(); openStreetMapFilePath = config.getOpenStreetMapFilePath(); isIndexOnlyPlan = config.getIsIndexOnlyPlan(); }
From source file:functionaltests.scilab.AbstractScilabTest.java
protected void runCommand(String testName, int nb_iter) throws Exception { ProcessBuilder pb = initCommand(testName, nb_iter); System.out.println("Running command : " + pb.command()); File okFile = new File(sci_tb_home + fs + "ok.tst"); File koFile = new File(sci_tb_home + fs + "ko.tst"); File reFile = new File(sci_tb_home + fs + "re.tst"); if (okFile.exists()) { okFile.delete();/*from ww w . j a va 2s . c o m*/ } if (koFile.exists()) { koFile.delete(); } if (reFile.exists()) { reFile.delete(); } Process p = pb.start(); IOTools.LoggingThread lt1 = new IOTools.LoggingThread(p.getInputStream(), "[" + testName + "]", System.out); Thread t1 = new Thread(lt1, testName); t1.setDaemon(true); t1.start(); p.waitFor(); if (reFile.exists()) { // we restart in case of JIMS loading bug runCommand(testName, nb_iter); return; } assertTrue(testName + " passed", okFile.exists()); if (testLeak == 1) { File outFile = new File(test_home + fs + "JIMS.out"); JIMSLogsParser parser = new JIMSLogsParser(leakFile, outFile); assertTrue("No leak found in " + outFile + " and " + leakFile, parser.testok()); } }
From source file:com.nesscomputing.event.jms.JmsEventReceiver.java
@OnStage(LifecycleStage.START) public void start() { final AbstractConsumer consumer = consumerHolder.get(); if (consumer != null) { Preconditions.checkState(consumerThreadHolder.get() == null, "already started, boldly refusing to start twice!"); final Thread consumerThread = new Thread(consumer, "ness-event-jms-consumer"); Preconditions.checkState(consumerThreadHolder.getAndSet(consumerThread) == null, "thread already set, this should not happen!"); consumerThread.setDaemon(true); consumerThread.start();/*from ww w.ja v a 2 s. co m*/ } else { LOG.debug("JMS seems to be disabled, skipping Event receiver start!"); } }
From source file:com.gs.jrpip.client.ThankYouWriter.java
private synchronized void startThankYouThread() { if (this.done) { this.done = false; Thread thankYouThread = new Thread(INSTANCE); thankYouThread.setName("JRPIP Thank You Thread"); thankYouThread.setDaemon(true); thankYouThread.start();//from w ww. j av a2 s . c o m } }
From source file:functionaltests.scilab.AbstractScilabTest.java
public void run() throws Throwable { init();//from w w w. j a v a 2 s .co m ProcessBuilder pb = new ProcessBuilder(); pb.directory(sci_tb_home); pb.redirectErrorStream(true); if (System.getProperty("scilab.bin.path") != null) { pb.command(System.getProperty("scilab.bin.path"), "-nw", "-f", (new File(test_home + fs + "PrepareTest.sci")).getCanonicalPath()); } else { pb.command("scilab", "-nw", "-f", (new File(test_home + fs + "PrepareTest.sci")).getCanonicalPath()); } System.out.println("Running command : " + pb.command()); File okFile = new File(sci_tb_home + fs + "ok.tst"); File koFile = new File(sci_tb_home + fs + "ko.tst"); if (okFile.exists()) { okFile.delete(); } if (koFile.exists()) { koFile.delete(); } Process p = pb.start(); IOTools.LoggingThread lt1 = new IOTools.LoggingThread(p.getInputStream(), "[AbstractScilabTest]", System.out); Thread t1 = new Thread(lt1, "AbstractScilabTest"); t1.setDaemon(true); t1.start(); p.waitFor(); assertTrue("Prepare Scilab Test passed", okFile.exists()); }
From source file:gov.va.isaac.mojos.profileSync.ProfilesMojoBase.java
protected String getUsername() throws MojoExecutionException { if (username == null) { username = System.getProperty(PROFILE_SYNC_USERNAME_PROPERTY); //still blank, try property if (StringUtils.isBlank(username)) { username = profileSyncUsername; }/* w w w . j ava 2s .c om*/ //still no username, prompt if allowed if (StringUtils.isBlank(username) && !Boolean.getBoolean(PROFILE_SYNC_NO_PROMPTS)) { Callable<Void> callable = new Callable<Void>() { @Override public Void call() throws Exception { if (!disableHintGiven) { System.out.println("To disable remote sync during build, add '-D" + PROFILE_SYNC_DISABLE + "=true' to your maven command"); disableHintGiven = true; } try { System.out.println("Enter the " + config_.getChangeSetUrlType().name() + " username for the Profiles/Changset remote store (" + config_.getChangeSetUrl() + "):"); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); username = br.readLine(); } catch (IOException e) { throw new MojoExecutionException("Error reading username from console"); } return null; } }; try { Executors.newSingleThreadExecutor(new ThreadFactory() { @Override public Thread newThread(Runnable r) { Thread t = new Thread(r, "User Prompt Thread"); t.setDaemon(true); return t; } }).submit(callable).get(2, TimeUnit.MINUTES); } catch (TimeoutException | InterruptedException e) { throw new MojoExecutionException("Username not provided within timeout"); } catch (ExecutionException ee) { throw (ee.getCause() instanceof MojoExecutionException ? (MojoExecutionException) ee.getCause() : new MojoExecutionException("Unexpected", ee.getCause())); } } } return username; }
From source file:eu.interedition.collatex.tools.CollationServer.java
public CollationServer(int maxParallelCollations, int maxCollationSize, String dotPath) { this.collationThreads = Executors.newFixedThreadPool(maxParallelCollations, new ThreadFactory() { private final AtomicLong counter = new AtomicLong(); @Override/*from w w w. j a va 2s.c o m*/ public Thread newThread(Runnable r) { final Thread t = new Thread(r, "collator-" + counter.incrementAndGet()); t.setDaemon(true); t.setPriority(Thread.MIN_PRIORITY); return t; } }); this.maxCollationSize = maxCollationSize; this.dotPath = dotPath; }