[Solved] Java: How to print odd and even numbers from 2 separate threads using Executor framework
Its a modified version of jasons: import java.util.concurrent.Executor; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicInteger; public class Test { public static void main(String[] args){ final int max = 100; final AtomicInteger i = new AtomicInteger(0); Executor dd = Executors.newFixedThreadPool(2); final Object lock = new Object(); dd.execute(new Runnable() { @Override public void run() { while (i.get() < max) { … Read more