Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class WorkerThread implements Runnable {
- int y;
- public WorkerThread(int y) {
- this.y = y;
- }
- @Override
- public void run(int x) {
- System.out.println(x+y);
- }
- }
- ExecutorService executor = Executors.newFixedThreadPool(5);
- for (int num: number) {
- Runnable worker = new WorkerThread(num);
- for (int anotherNum : anotherNumbers) {
- executor.execute(worker.run(anotherNum));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement