Question: Which method can fill in the blank that would cause the program to consistently print Tie! ten times? A. lock() B. tryLock() C. tryLock(10) D.
Which method can fill in the blank that would cause the program to consistently print Tie! ten times?

A. lock()
B. tryLock()
C. tryLock(10)
D. The code does not compile regardless of what is placed in the blank.
E. None of the above.
import java.util.concurrent.*; import public class TieShoes { java.util.concurrent.locks.*; private Lock shoes = new ReentrantLock(); public void tie() { try { } } if (shoes.. } System.out.println("Tie!"); shoes.unlock(); } } catch (Exception e) {} ) { } public static void main (String... unused) { var gate= new TieShoes(); for (int i = 0; i gate.tie()).start();
Step by Step Solution
3.37 Rating (169 Votes )
There are 3 Steps involved in it
The code snippet provided is attempting to manage access to a shared resource in this case represented by the shoes lock using Javas javautilconcurren... View full answer
Get step-by-step solutions from verified subject matter experts
