public void ShutdownNoContinueExisting() { ScheduledThreadPoolExecutor e = new ScheduledThreadPoolExecutor(5, Executors.DefaultThreadFactory()); e.SetExecuteExistingDelayedTasksAfterShutdownPolicy(false); bool run = false; e.Schedule(new RunnableAction(delegate { run = true; }), 100, TimeUnit.MILLISECONDS); Thread.Sleep(50); e.Shutdown(); Assert.IsTrue(e.IsShutdown()); Assert.IsTrue(e.IsTerminated(), "Terminated"); Assert.IsFalse(e.IsTerminating(), "Terminating"); Thread.Sleep(100); Assert.IsFalse(run); Assert.IsTrue(e.IsTerminated(), "Terminated"); Assert.IsFalse(e.IsTerminating(), "Terminating"); }
public void ShutdownNow() { ScheduledThreadPoolExecutor e = new ScheduledThreadPoolExecutor(5, Executors.DefaultThreadFactory()); bool run = false; e.Schedule(new RunnableAction(delegate { run = true; }), 100, TimeUnit.MILLISECONDS); Thread.Sleep(50); var pending = e.ShutdownNow(); Assert.AreEqual(0, pending.Count); Assert.IsTrue(e.IsShutdown()); Assert.IsTrue(e.IsTerminated(), "Terminated"); Assert.IsFalse(e.IsTerminating(), "Terminating"); Thread.Sleep(100); Assert.IsFalse(run); Assert.IsTrue(e.IsTerminated(), "Terminated"); Assert.IsFalse(e.IsTerminating(), "Terminating"); }
public virtual void TestShutdownThreadPool() { ScheduledThreadPoolExecutor executor = new ScheduledThreadPoolExecutor(1); executor.Execute(sampleRunnable); bool ret = ShutdownThreadsHelper.ShutdownExecutorService(executor); bool isTerminated = executor.IsTerminated(); Assert.Equal("Incorrect return value", ret, isTerminated); Assert.True("ExecutorService is not shutdown", isTerminated); }
public void Shutdown() { ScheduledThreadPoolExecutor e = new ScheduledThreadPoolExecutor (5, Executors.DefaultThreadFactory ()); bool run = false; e.Schedule (new RunnableAction (delegate { run = true; }),100, TimeUnit.MILLISECONDS); Thread.Sleep (50); e.Shutdown (); Assert.IsTrue (e.IsShutdown ()); Assert.IsFalse (e.IsTerminated (), "Terminated"); Assert.IsTrue (e.IsTerminating (), "Terminating"); Thread.Sleep (100); Assert.IsTrue (run, "Not run"); Assert.IsTrue (e.IsTerminated (), "Terminated"); Assert.IsFalse (e.IsTerminating (), "Terminating"); }
public void ShutdownNoContinueExisting () { ScheduledThreadPoolExecutor e = new ScheduledThreadPoolExecutor (5, Executors.DefaultThreadFactory ()); e.SetExecuteExistingDelayedTasksAfterShutdownPolicy (false); bool run = false; e.Schedule (new RunnableAction (delegate { run = true; }),100, TimeUnit.MILLISECONDS); Thread.Sleep (50); e.Shutdown (); Assert.IsTrue (e.IsShutdown ()); Assert.IsTrue (e.IsTerminated (), "Terminated"); Assert.IsFalse (e.IsTerminating (), "Terminating"); Thread.Sleep (100); Assert.IsFalse (run); Assert.IsTrue (e.IsTerminated (), "Terminated"); Assert.IsFalse (e.IsTerminating (), "Terminating"); }