private static byte[] findFirstMatchingHardwareAddress(List<NetworkInterface> ifaces) { ExecutorService executor = Executors.newFixedThreadPool(ifaces.size(), ActiveMQThreadFactory.defaultThreadFactory()); Collection<Callable<byte[]>> tasks = new ArrayList<>(ifaces.size());
@Override public ThreadFactory run() { return new ActiveMQThreadFactory("ActiveMQ-client-global-scheduled-threads", true, ClientSessionFactoryImpl.class.getClassLoader()); } });
@Override public Thread newThread(final Runnable command) { // create a thread in a privileged block if running with Security Manager if (acc != null) { return AccessController.doPrivileged(new ThreadCreateAction(command), acc); } else { return createThread(command); } }
@Override @Before public void setUp() throws Exception { super.setUp(); pollerExecutor = Executors.newCachedThreadPool(new ActiveMQThreadFactory("ActiveMQ-AIO-poller-pool" + System.identityHashCode(this), false, this.getClass().getClassLoader())); executor = Executors.newSingleThreadExecutor(ActiveMQThreadFactory.defaultThreadFactory()); }
public static synchronized void resetThreadPool() { if (threadPoolExecutor != null) { threadPoolExecutor.shutdownNow(); if (threadPoolExecutor instanceof ThreadPoolExecutor) { ThreadPoolExecutor tp = (ThreadPoolExecutor) threadPoolExecutor; if (tp.getThreadFactory() instanceof ActiveMQThreadFactory) { ActiveMQThreadFactory tf = (ActiveMQThreadFactory)tp.getThreadFactory(); if (!tf.join(10, TimeUnit.SECONDS)) { // resetThreadPool is only used on tests. // no need to use a logger method, this is just fine. logger.warn("Thread pool is still busy. couldn't stop on time"); } } } threadPoolExecutor = null; } }
try { ExecutorService executor = Executors.newFixedThreadPool(1, ActiveMQThreadFactory.defaultThreadFactory()); executor.shutdownNow(); } catch (Throwable t) {
@Override public ThreadFactory run() { return new ActiveMQThreadFactory("ActiveMQ-client-netty-threads", true, ClientSessionFactoryImpl.class.getClassLoader()); } })));
@Override public Thread newThread(final Runnable command) { // create a thread in a privileged block if running with Security Manager if (acc != null) { return AccessController.doPrivileged(new ThreadCreateAction(command), acc); } else { return createThread(command); } }
private static synchronized ExecutorService getInVMExecutor() { if (threadPoolExecutor == null) { if (ActiveMQClient.getGlobalThreadPoolSize() <= -1) { threadPoolExecutor = new ThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>(), ActiveMQThreadFactory.defaultThreadFactory()); } else { threadPoolExecutor = new ActiveMQThreadPoolExecutor(0, ActiveMQClient.getGlobalThreadPoolSize(), 60L, TimeUnit.SECONDS, ActiveMQThreadFactory.defaultThreadFactory()); } } return threadPoolExecutor; }
@Override public ThreadFactory run() { return new ActiveMQThreadFactory("ActiveMQ-client-global-threads", true, ClientSessionFactoryImpl.class.getClassLoader()); } });
@Override public Thread newThread(final Runnable command) { // create a thread in a privileged block if running with Security Manager if (acc != null) { return AccessController.doPrivileged(new ThreadCreateAction(command), acc); } else { return createThread(command); } }
private static byte[] findFirstMatchingHardwareAddress(List<NetworkInterface> ifaces) { ExecutorService executor = Executors.newFixedThreadPool(ifaces.size(), ActiveMQThreadFactory.defaultThreadFactory()); Collection<Callable<byte[]>> tasks = new ArrayList<>(ifaces.size());
@Override public ThreadFactory run() { return new ActiveMQThreadFactory("ActiveMQ-client-factory-threads-" + System.identityHashCode(this), true, ClientSessionFactoryImpl.class.getClassLoader()); } });
@Override public Thread newThread(final Runnable command) { // create a thread in a privileged block if running with Security Manager if (acc != null) { return AccessController.doPrivileged(new ThreadCreateAction(command), acc); } else { return createThread(command); } }
private static byte[] findFirstMatchingHardwareAddress(List<NetworkInterface> ifaces) { ExecutorService executor = Executors.newFixedThreadPool(ifaces.size(), ActiveMQThreadFactory.defaultThreadFactory()); Collection<Callable<byte[]>> tasks = new ArrayList<>(ifaces.size());
@Override public ThreadFactory run() { return new ActiveMQThreadFactory("ActiveMQ-client-factory-pinger-threads-" + System.identityHashCode(this), true, ClientSessionFactoryImpl.class.getClassLoader()); } });
@Override public Thread newThread(final Runnable command) { // create a thread in a privileged block if running with Security Manager if (acc != null) { return AccessController.doPrivileged(new ThreadCreateAction(command), acc); } else { return createThread(command); } }
private static byte[] findFirstMatchingHardwareAddress(List<NetworkInterface> ifaces) { ExecutorService executor = Executors.newFixedThreadPool(ifaces.size(), ActiveMQThreadFactory.defaultThreadFactory()); Collection<Callable<byte[]>> tasks = new ArrayList<>(ifaces.size());
public static ActiveMQThreadFactory defaultThreadFactory() { String callerClassName = Thread.currentThread().getStackTrace()[2].getClassName(); return new ActiveMQThreadFactory(callerClassName, false, null); }
@Override public Thread newThread(final Runnable command) { // create a thread in a privileged block if running with Security Manager if (acc != null) { return AccessController.doPrivileged(new ThreadCreateAction(command), acc); } else { return createThread(command); } }