List of usage examples for java.util.concurrent Executors newSingleThreadExecutor
public static ExecutorService newSingleThreadExecutor(ThreadFactory threadFactory)
From source file:Main.java
/** * Creates an Executor that uses a single worker thread operating off an unbounded queue, and uses the provided * ThreadFactory to create a new thread when needed. Unlike the otherwise equivalent * {@code newFixedThreadPool(1, threadFactory)} the returned executor is guaranteed not to be reconfigurable to use * additional threads./*from w ww .j a v a 2s . c o m*/ * * @param name * the name of the new thread * * @return the newly created single-threaded Executor * @throws NullPointerException * if threadFactory is null */ public static final ExecutorService buildNewSingleThreadExecutor(final String name) { return Executors.newSingleThreadExecutor(getThreadFactory(name)); }
From source file:Main.java
public static ExecutorService createSingleThreadExecutor(final String name) { return Executors.newSingleThreadExecutor(createSimpleThreadFactory(name)); }
From source file:com.lightbox.android.bitmap.BitmapFileCleanerTask.java
private static ExecutorService getExecutor() { if (sBitmapFileCleanerExecutor == null) { sBitmapFileCleanerExecutor = Executors.newSingleThreadExecutor(new ThreadFactory() { @Override//from w w w. j a v a 2 s . com public Thread newThread(Runnable r) { Thread thread = new Thread(r); thread.setName(TAG + " | " + thread.getName()); thread.setPriority(Thread.MIN_PRIORITY); return thread; } }); } return sBitmapFileCleanerExecutor; }
From source file:br.com.uol.runas.service.JUnitService.java
public JUnitServiceResponse runTests(String path, final String[] suites) throws Exception { try (final JarClassLoader classLoader = new JarClassLoader(path, classLoaderGC)) { final ThreadFactory threadFactory = new ThreadFactoryImpl(classLoader); final ExecutorService service = Executors.newSingleThreadExecutor(threadFactory); try {/*from www.j a v a 2 s. c om*/ return service.submit(new JUnitTask(suites)).get(); } finally { service.shutdownNow(); } } }
From source file:net.brtly.monkeyboard.adb.DeviceThreadPool.java
protected void addThread(String serial) { LOG.trace("Adding thread: Device-thread-" + serial + "-%d"); _threads.put(serial, Executors.newSingleThreadExecutor( new ThreadFactoryBuilder().setNameFormat("Device-thread-" + serial + "-%d").build())); }
From source file:ch.algotrader.wiring.adapter.IBSessionReconnector.java
public IBSessionReconnector(final String name, final IBSession session) { Validate.notEmpty(name, "Session name is null"); Validate.notNull(session, "IBSession is null"); this.name = name; this.session = session; this.executorService = Executors .newSingleThreadExecutor(new BasicThreadFactory("IB-reconnect-thread", true)); }
From source file:de.jackwhite20.japs.client.pub.impl.PublisherImpl.java
public PublisherImpl(List<ClusterServer> clusterServers) { super(clusterServers); this.executorService = Executors.newSingleThreadExecutor(r -> { Thread thread = Executors.defaultThreadFactory().newThread(r); thread.setName("AsyncPublisher Thread"); return thread; });/*from w w w. ja v a2 s .c om*/ this.asyncPublisher = new AsyncPublisherImpl(executorService, this); }
From source file:com.alibaba.dragoon.common.protocol.transport.socket.SocketConnector.java
public SocketConnector() { connectorExecutor = Executors.newSingleThreadExecutor(new DaemonThreadFactory("SocketConnecor")); }
From source file:com.baidu.cc.ConfigChangedListener.java
/** * start listener thread// w ww .ja va 2 s. c om */ public synchronized void start() { if (es == null) { ThreadFactoryBuilder tfbuilder = new ThreadFactoryBuilder(); tfbuilder.setNameFormat("ConfigChangedListener-Thread"); es = Executors.newSingleThreadExecutor(tfbuilder.build()); } stop = false; es.execute(this); }
From source file:de.jackwhite20.japs.client.cache.impl.PubSubCacheImpl.java
public PubSubCacheImpl(List<ClusterServer> clusterServers) { super(clusterServers); this.executorService = Executors.newSingleThreadExecutor(r -> { Thread thread = Executors.defaultThreadFactory().newThread(r); thread.setName("PubSubCache Thread"); return thread; });// w w w .j av a2s . c o m this.asyncPubSubCache = new AsyncPubSubCacheImpl(executorService, this); }