List of usage examples for java.util.concurrent Executors defaultThreadFactory
public static ThreadFactory defaultThreadFactory()
From source file:com.alibaba.napoli.gecko.service.timer.HashedWheelTimer.java
/** * Creates a new timer with the default thread factory ( * {@link Executors#defaultThreadFactory()}), default tick duration, and * default number of ticks per wheel./* w ww. j a v a 2 s .c o m*/ */ public HashedWheelTimer() { this(Executors.defaultThreadFactory()); }
From source file:com.mdsh.test.media.encoding.process.AbstractProcess.java
/** * Creates a thread to read from a Stream and send a ProcessLogEvent * for each line read from the stream./* w ww.ja va 2 s .c om*/ * @param is the InputStream to read from * @param handler the handler to send ProcessLogEvents to * @return */ protected Thread createProcessLogEventHandlerThread(final InputStream is, final ProcessLogEventHandler handler) { final BufferedReader reader = new BufferedReader(new InputStreamReader(is)); return Executors.defaultThreadFactory().newThread(new Runnable() { @Override public void run() { getLogger().trace("thread started"); readerToHandler(reader, handler); // alert that process has finished getLogger().trace("thread finished"); } }); }
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 . j a va 2 s . co 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:hudson.cli.CLI.java
/** * @deprecated Specific to {@link Mode#REMOTING}. *//*w ww .j av a2 s. c o m*/ @Deprecated /*package*/ CLI(CLIConnectionFactory factory) throws IOException, InterruptedException { URL jenkins = factory.jenkins; this.httpsProxyTunnel = factory.httpsProxyTunnel; this.authorization = factory.authorization; ExecutorService exec = factory.exec; ownsPool = exec == null; pool = exec != null ? exec : Executors .newCachedThreadPool(new NamingThreadFactory(Executors.defaultThreadFactory(), "CLI.pool")); Channel _channel; try { _channel = connectViaCliPort(jenkins, getCliTcpPort(jenkins)); } catch (IOException e) { LOGGER.log(Level.FINE, "Failed to connect via CLI port. Falling back to HTTP", e); try { _channel = connectViaHttp(jenkins); } catch (IOException e2) { e.addSuppressed(e2); throw e; } } this.channel = _channel; // execute the command entryPoint = (CliEntryPoint) _channel.waitForRemoteProperty(CliEntryPoint.class.getName()); if (entryPoint.protocolVersion() != CliEntryPoint.VERSION) throw new IOException(Messages.CLI_VersionMismatch()); }
From source file:net.rptools.tokentool.controller.ManageOverlays_Controller.java
@FXML void initialize() { assert overlayViewFlowPane != null : "fx:id=\"overlayViewFlowPane\" was not injected: check your FXML file 'ManageOverlays.fxml'."; assert overlayTreeView != null : "fx:id=\"overlayTreeView\" was not injected: check your FXML file 'ManageOverlays.fxml'."; assert detailsVBox != null : "fx:id=\"detailsVBox\" was not injected: check your FXML file 'ManageOverlays.fxml'."; assert overlayName != null : "fx:id=\"overlayName\" was not injected: check your FXML file 'ManageOverlays.fxml'."; assert overlayDescription != null : "fx:id=\"overlayDescription\" was not injected: check your FXML file 'ManageOverlays.fxml'."; assert overlayDimensions != null : "fx:id=\"overlayDimensions\" was not injected: check your FXML file 'ManageOverlays.fxml'."; assert overlayLayerImage != null : "fx:id=\"overlayLayerImage\" was not injected: check your FXML file 'ManageOverlays.fxml'."; assert overlayLayerMask != null : "fx:id=\"overlayLayerMask\" was not injected: check your FXML file 'ManageOverlays.fxml'."; assert addOverlayButton != null : "fx:id=\"addOverlayButton\" was not injected: check your FXML file 'ManageOverlays.fxml'."; assert deleteOverlayButton != null : "fx:id=\"deleteOverlayButton\" was not injected: check your FXML file 'ManageOverlays.fxml'."; assert addFolderButton != null : "fx:id=\"addFolderButton\" was not injected: check your FXML file 'ManageOverlays.fxml'."; assert deleteFolderButton != null : "fx:id=\"deleteFolderButton\" was not injected: check your FXML file 'ManageOverlays.fxml'."; assert restoreButton != null : "fx:id=\"restoreButton\" was not injected: check your FXML file 'ManageOverlays.fxml'."; executorService = Executors.newSingleThreadScheduledExecutor(runable -> { loadOverlaysThread = Executors.defaultThreadFactory().newThread(runable); loadOverlaysThread.setDaemon(true); return loadOverlaysThread; });//from ww w.java 2 s.c om // Add a listener to the TreeView overlayTreeView.getSelectionModel().selectedItemProperty() .addListener((observable, oldValue, newValue) -> loadImages(newValue)); displayTreeView(); }
From source file:io.github.mmichaelis.selenium.client.provider.AbstractWebDriverProviderTest.java
@Test public void reset_does_nothing_if_not_started() throws Exception { final WebDriverProvider driverProvider = new NoExceptionWebDriverProvider(defaultDriver); final Thread thread = Executors.defaultThreadFactory().newThread(new Runnable() { @Override//from w w w .j av a 2s .c o m public void run() { driverProvider.reset(); } }); thread.start(); thread.join(); errorCollector.checkSucceeds(new Callable<Object>() { @Nullable @Override public Object call() { verify(defaultDriver, never()).navigate(); return null; } }); errorCollector.checkSucceeds(new Callable<Object>() { @Nullable @Override public Object call() { verify(defaultDriver, never()).manage(); return null; } }); errorCollector.checkSucceeds(new Callable<Object>() { @Nullable @Override public Object call() { verify(defaultDriver, never()).getWindowHandle(); return null; } }); errorCollector.checkSucceeds(new Callable<Object>() { @Nullable @Override public Object call() { verify(defaultDriver, never()).getWindowHandles(); return null; } }); }
From source file:com.alibaba.napoli.gecko.service.timer.HashedWheelTimer.java
/** * Creates a new timer with the default thread factory ( * {@link Executors#defaultThreadFactory()}) and default number of ticks per * wheel./*from w ww . j av a 2s . c o m*/ * * @param tickDuration * the duration between tick * @param unit * the time unit of the {@code tickDuration} */ public HashedWheelTimer(final long tickDuration, final TimeUnit unit) { this(Executors.defaultThreadFactory(), tickDuration, unit); }
From source file:org.apache.bookkeeper.util.OrderedSafeExecutor.java
@Deprecated public OrderedSafeExecutor(int numThreads, String threadName) { this(threadName, numThreads, Executors.defaultThreadFactory(), NullStatsLogger.INSTANCE, false, WARN_TIME_MICRO_SEC_DEFAULT); }
From source file:com.taobao.metamorphosis.gregor.slave.OrderedThreadPoolExecutor.java
/** * Creates a default ThreadPool, with default values : - A default * ThreadFactory - All events are accepted * /*from w w w . jav a2s. c om*/ * @param corePoolSize * The initial pool sizePoolSize * @param maximumPoolSize * The maximum pool size * @param keepAliveTime * Default duration for a thread * @param unit * Time unit used for the keepAlive value */ public OrderedThreadPoolExecutor(final int corePoolSize, final int maximumPoolSize, final long keepAliveTime, final TimeUnit unit) { this(corePoolSize, maximumPoolSize, keepAliveTime, unit, Executors.defaultThreadFactory()); }
From source file:tv.arte.resteventapi.core.scheduling.RestEventScheduledThreadPoolExecutorScheduler.java
/** * Defines the scheduler configuring the amount of minutes between automatic rescheduling * /*from w w w. j a va2 s . c o m*/ * @see ScheduledThreadPoolExecutor#ScheduledThreadPoolExecutor(int) */ public RestEventScheduledThreadPoolExecutorScheduler(int corePoolSize, Integer secondsBetweenRescheduling, Integer maxMinutesToPrefetchScheduledEvents) { this(corePoolSize, Executors.defaultThreadFactory(), new ThreadPoolExecutor.DiscardPolicy(), secondsBetweenRescheduling, maxMinutesToPrefetchScheduledEvents); }