GenericTaskManager { public GenericTaskManager(String name) { this(name, 1); } GenericTaskManager(String name);   GenericTaskManager(String name, int n); final void updateManaged(); final void dispose(); final boolean runManagedTask(ManagedTask<T> task, long timeout, TimeUnit timeoutUnit); final void runManagedTask(ManagedTask<T> task); final void recoverInvalid();  }
@Test public void testGenericTaskManager() throws InterruptedException { TestTaskManager manager = new TestTaskManager(); List<String> result = Collections.synchronizedList(new ArrayList<String>()); new TestGenericTask("t1", manager, 100, 100, result).start(); new TestGenericTask("t2", manager, 150, 100, result).start(); new TestGenericUpdateTask(manager, 150).start(); new TestGenericTask("t3", manager, 200, 100, result).start(); TestGenericTask thread = new TestGenericTask("t4", manager, 300, 100, result); thread.start(); thread.join(); assertArrayEquals(new String[] { "t1v1", "t2v1", "t3v2", "t4v2" }, result.toArray(new String[0])); }