Advertisement
mrityunjay2002

multithreading

Oct 16th, 2011
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 0.54 KB | None | 0 0
  1.  public static List<Item> parse() {
  2.     CountDownLatch latch = new CountDownLatch(1000);
  3.         for (int i = 1; i <= 1000; i++) {
  4.         Executor executor = Executors.newFixedThreadPool(20);
  5.             Parser thread = new Parser(latch);
  6.             thread.setName(Integer.toString(i));
  7.             threadCount++; //increase the number of working threads
  8.             executor.submit(thread);            
  9.         }
  10.     latch.await();
  11.         return itemList;
  12. }
  13.  
  14. public void run() {
  15.     // jsut add the line after you code
  16.     latch.countDown();
  17. }
  18.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement