Question: Question 1: Consider the following Bakery lock. It has been initialized for five threads, with threadIDs 0, 1, 2, 3 and 4. Initially, the Label
Question 1:
Consider the following Bakery lock. It has been initialized for five threads, with threadIDs 0, 1, 2, 3 and 4.
Initially, the Label array is {0, 0, 0, 0, 0}.
The flag array is {false, false, false, false, false}.
No thread has entered the lock method.
Then, thread 3 enters the lock method, and completes through line 15.
Blank 1: What are the contents of the label array? Use the same format as shown above.
Blank 2: What are the contents of the flag array? Use the same format as shown above.

Question 2:
Consider the following Bakery lock. It has been initialized for five threads, with threadIDs 0, 1, 2, 3 and 4.
Initially, the Label array is {0, 0, 0, 0, 0}.
The flag array is {false, false, false, false, false}.
No thread has entered the lock method.
Then, thread 3 enters the lock method, and completes through line 15. Then, thread 0 enters the lock method and completes through line 15. Then, thread 1 enters the lock method and completes through line 15.
Blank 1: What are the contents of the label array? Use the same format as shown above.
Blank 2: What are the contents of the flag array? Use the same format as shown above.

1 2 3 4 5 class Bakery implements Lock { boolean[] flag; Label [] label; public Bakery (int n) { flag = new boolean[n]; label = new Label [n]; for (int i = 0; i
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
