Ask Question
27 December, 13:07

Recall that the Counter class initializes itself to 0 and allows a client to increment it, and the Increase class is initialized with a Counter c and an int amount and when run, invokes increment on the Counter object c amount times. Identify the possible output of the following code sequence: Counter c = new Counter (); Runnable r = new Increase (c, 2); Thread t = new Thread (r); c. increment (); t. start (); System. out. println (c);

+3
Answers (1)
  1. 27 December, 13:50
    0
    Output can be 0 or 1 or 2.

    Explanation:

    As we are initializing the value with 2 so at most it will increment to 2 times means value will be 2.

    when main thread is printing the c, Increase thread might be started or might not be started

    so output can be 0 or 1 or 2
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Recall that the Counter class initializes itself to 0 and allows a client to increment it, and the Increase class is initialized with a ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers