MultiResourceTaskManager { @SuppressWarnings("unchecked") public final void runManagedTask(MultiResourceManagedTask<RESOURCETYPE, INFOTYPE> task, INFOTYPE...requested) throws InvalidManagedInstanceException { List<RESOURCETYPE> managed = null; List<Modified> modifiedList = null; try { managed = getManaged(requested); modifiedList = task.run(managed); } finally { if (managed != null) { returnManaged(managed, modifiedList, requested); } } } @SuppressWarnings("unchecked") protected  MultiResourceTaskManager(String name, GenericTaskManager<RESOURCETYPE>...managers); @SuppressWarnings("unchecked") final void runManagedTask(MultiResourceManagedTask<RESOURCETYPE, INFOTYPE> task,
			INFOTYPE...requested);  }
@Test public void testRunManagedTask() throws Exception { TestGenericTaskManager[] managers = createManagerList(); MultiResourceTaskManager<String, String> testManager = createMultiTaskManager(managers); List<String> events = Collections.synchronizedList(new ArrayList<String>()); List<Thread> threads = new ArrayList<Thread>(); threads.add(new TestMultiThread(testManager, events, "A", "B")); threads.add(new TestMultiThread(testManager, events, "C", "D")); threads.add(new TestMultiThread(testManager, events, "B", "C")); threads.add(new TestMultiThread(testManager, events, "A", "B")); for (Thread thread : threads) { thread.start(); Thread.sleep(10); } for (Thread thread : threads) { thread.join(); } assertEquals(4, events.size()); assertEquals("[A, B]100", events.get(0)); assertEquals("[C, D]100", events.get(1)); assertEquals("[B, C]590", events.get(2)); assertEquals("[A, B]1080", events.get(3)); }