/** * @param service {@link ExecutorService to be shutdown} * @return <tt>true</tt> if the service is terminated, * <tt>false</tt> otherwise * @throws InterruptedException */ public static boolean shutdownExecutorService(ExecutorService service) throws InterruptedException { return shutdownExecutorService(service, SHUTDOWN_WAIT_MS); }
/** * @param thread {@link Thread to be shutdown} * @return <tt>true</tt> if the thread is successfully interrupted, * <tt>false</tt> otherwise * @throws InterruptedException */ public static boolean shutdownThread(Thread thread) { return shutdownThread(thread, SHUTDOWN_WAIT_MS); }
/** * @param service {@link ExecutorService to be shutdown} * @return <tt>true</tt> if the service is terminated, * <tt>false</tt> otherwise * @throws InterruptedException */ public static boolean shutdownExecutorService(ExecutorService service) throws InterruptedException { return shutdownExecutorService(service, SHUTDOWN_WAIT_MS); }
/** * @param thread {@link Thread to be shutdown} * @return <tt>true</tt> if the thread is successfully interrupted, * <tt>false</tt> otherwise * @throws InterruptedException */ public static boolean shutdownThread(Thread thread) { return shutdownThread(thread, SHUTDOWN_WAIT_MS); }
/** * @param service {@link ExecutorService to be shutdown} * @return <tt>true</tt> if the service is terminated, * <tt>false</tt> otherwise * @throws InterruptedException */ public static boolean shutdownExecutorService(ExecutorService service) throws InterruptedException { return shutdownExecutorService(service, SHUTDOWN_WAIT_MS); }
/** * @param thread {@link Thread to be shutdown} * @return <tt>true</tt> if the thread is successfully interrupted, * <tt>false</tt> otherwise * @throws InterruptedException */ public static boolean shutdownThread(Thread thread) { return shutdownThread(thread, SHUTDOWN_WAIT_MS); }
/** * @param service {@link ExecutorService to be shutdown} * @return <tt>true</tt> if the service is terminated, * <tt>false</tt> otherwise * @throws InterruptedException */ public static boolean shutdownExecutorService(ExecutorService service) throws InterruptedException { return shutdownExecutorService(service, SHUTDOWN_WAIT_MS); }
/** * @param thread {@link Thread to be shutdown} * @return <tt>true</tt> if the thread is successfully interrupted, * <tt>false</tt> otherwise * @throws InterruptedException */ public static boolean shutdownThread(Thread thread) { return shutdownThread(thread, SHUTDOWN_WAIT_MS); }
/** * @param service {@link ExecutorService to be shutdown} * @return <tt>true</tt> if the service is terminated, * <tt>false</tt> otherwise * @throws InterruptedException */ public static boolean shutdownExecutorService(ExecutorService service) throws InterruptedException { return shutdownExecutorService(service, SHUTDOWN_WAIT_MS); }
/** * @param thread {@link Thread to be shutdown} * @return <tt>true</tt> if the thread is successfully interrupted, * <tt>false</tt> otherwise * @throws InterruptedException */ public static boolean shutdownThread(Thread thread) { return shutdownThread(thread, SHUTDOWN_WAIT_MS); }
@Override public void serviceStop() throws Exception { ShutdownThreadsHelper.shutdownExecutorService(moveToDoneExecutor); super.serviceStop(); }
@Test (timeout = 3000) public void testShutdownThread() { Thread thread = new Thread(sampleRunnable); thread.start(); boolean ret = ShutdownThreadsHelper.shutdownThread(thread); boolean isTerminated = !thread.isAlive(); assertEquals("Incorrect return value", ret, isTerminated); assertTrue("Thread is not shutdown", isTerminated); }
@Override public void serviceStop() throws Exception { ShutdownThreadsHelper.shutdownExecutorService(moveToDoneExecutor); super.serviceStop(); }
@Test (timeout = 3000) public void testShutdownThread() { Thread thread = new Thread(sampleRunnable); thread.start(); boolean ret = ShutdownThreadsHelper.shutdownThread(thread); boolean isTerminated = !thread.isAlive(); assertEquals("Incorrect return value", ret, isTerminated); assertTrue("Thread is not shutdown", isTerminated); }
@Override public void serviceStop() throws Exception { ShutdownThreadsHelper.shutdownExecutorService(moveToDoneExecutor); super.serviceStop(); }
@Test public void testShutdownThreadPool() throws InterruptedException { ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1); executor.execute(sampleRunnable); boolean ret = ShutdownThreadsHelper.shutdownExecutorService(executor); boolean isTerminated = executor.isTerminated(); assertEquals("Incorrect return value", ret, isTerminated); assertTrue("ExecutorService is not shutdown", isTerminated); } }
@Test public void testShutdownThreadPool() throws InterruptedException { ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1); executor.execute(sampleRunnable); boolean ret = ShutdownThreadsHelper.shutdownExecutorService(executor); boolean isTerminated = executor.isTerminated(); assertEquals("Incorrect return value", ret, isTerminated); assertTrue("ExecutorService is not shutdown", isTerminated); } }