Results 1 to 1 of 1
- 12-13-2013, 05:23 PM #1
Member
- Join Date
- Oct 2013
- Posts
- 51
- Rep Power
- 0
terminating threads in newThreadPool
First of all, i could not find newThreadPool in Oracle docs, could you?
I have program like this :
Java Code:public static void main(String argv[]) throws InterruptedException { A[] arrayOfA = new A[]{new A(1),new A(2),new A(3),new A(4),new A(5)}; ExecutorService executor = Executors.newFixedThreadPool(3); for(A Aelem : arrayOfA) { executor.invokeAll((Collection<? extends Callable<A>>) Arrays.asList(Executors.callable(Aelem)), 1, TimeUnit.SECONDS); // Timeout of 1 second Thread.sleep(1000); } executor.shutdown(); }
Java Code:public class A implements Runnable { A otherThread = null; Integer i = null; public A(Integer i) { this.i = i; } public void run() { while(true) { System.out.println(i); } }
But somehow all threads keep working despite of 1 second timeout. How can i solve this task?
Similar Threads
-
Terminating execution of a JFrame without terminating execution of child frames...
By nish.singha20 in forum AWT / SwingReplies: 6Last Post: 11-30-2011, 09:39 PM -
Terminating a Thread
By Lil_Aziz1 in forum Threads and SynchronizationReplies: 4Last Post: 01-31-2010, 11:30 PM -
RMI Server Randomly Terminating
By danberg in forum NetworkingReplies: 2Last Post: 04-26-2009, 04:36 AM -
forcibly terminating io operations
By arnab321 in forum CLDC and MIDPReplies: 2Last Post: 11-15-2008, 09:51 PM -
terminating a while loop with a string
By tkdvipers in forum New To JavaReplies: 3Last Post: 07-10-2007, 12:23 AM
Bookmarks