Question 1
Consider the Java code given below, and answer the question that follows:
abstract class Operation implements Runnable { static int total = 10;}class Operation1 extends Operation { public void run() { if (total != 8) { total = total - 3; } }}class Operation2 extends Operation { public void run() { if (total != 7) { total = total - 2; } }}public class RaceConditionDecrement { public static void main(String[] args) { Operation op1 = new Operation1(); Operation op2 = new Operation2(); Thread t1 = new Thread(op1); Thread t2 = new Thread(op2); t1.start(); t2.start(); System.out.println(Operation.total); }}Choose the correct option.
The program will never generate the output: 5
The program will never generate the output: 7
The program will never generate the output: 8
The program will never generate the output: 10
The output can be 5 or 7 or 8 or 10.