hi could someone please help me understand how interference might occur in this program ?
class ThreadTest implements Runnable { static String printString = null; private String threadName; ThreadTest(String s) { threadName = s; } public void run() { int i = 0; while (i < 100) { if (printString == null) { printString = threadName + (++i); } else { System.out.println(printString); printString = null; } } } public static void main(String[] args) { Thread t1 = new Thread(new ThreadTest("a")); Thread t2 = new Thread(new ThreadTest("b")); t1.start(); t2.start(); } }
its meant to print a1 to a100 and b1 to b100...