Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. public class WorkerThread implements Runnable {
  2. int y;
  3.  
  4. public WorkerThread(int y) {
  5. this.y = y;
  6.  
  7. }
  8.  
  9. @Override
  10. public void run(int x) {
  11. System.out.println(x+y);
  12. }
  13. }
  14.  
  15. ExecutorService executor = Executors.newFixedThreadPool(5);
  16.  
  17. for (int num: number) {
  18. Runnable worker = new WorkerThread(num);
  19. for (int anotherNum : anotherNumbers) {
  20. executor.execute(worker.run(anotherNum));
  21. }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement