Question 1
Consider the code given below.
class Shared { static int count = 2000;}class Subtractor extends Thread { public void run() { for (int i = 0; i < 1000; i++) { Shared.count--; } }}public class Test { public static void main(String[] args) throws InterruptedException { Thread t1 = new Subtractor(); Thread t2 = new Subtractor(); t1.start(); t2.start(); t1.join(); t2.join(); System.out.print(Shared.count); }}Choose the correct option.
The code always prints 2000.
The code prints any number in the range 1000 to 2000
The code prints any number in the range 0 to 1000
The code always prints 1000.
