Document last modified:
1. (4 pts) What is one possible sequence of instructions executed for the complete program?
3, 4, 5, 6, 16-18, 6, 20-26,
5, 6, 16-18, 6, 20-26,
5, 6, 16-18, 6,
20-26,
8, 9, 10
|
2. (4 pts) What is reasonable expected output?
[Start Thread 1]
{Working Thread 1 <a>}
{Working Thread 1 <b>}
[Start Thread 3]
main completed
{Working Thread 1 <c>}
[Start Thread 2]
{Working Thread 3 <a>}
[Completed Thread 1]
{Working Thread 2 <a>}
{Working Thread 3 <b>}
{Working Thread 2 <b>}
{Working Thread 3 <c>}
{Working Thread 2 <c>}
[Completed Thread 3]
[Completed Thread 2]
3. (1 pts) Are other outputs possible? Yes
4. (4 pts) What is the sequence of instructions executed for the complete program?
3, 4, 5, 6, 17-20, 6,
5, 6, 17-20, 6,
5, 6, 17-20, 6, 7-9
22-26,
22-25,
22-25,
27, 26, 27, 26, 27, 28-30
26, 27, 26, 27, 26, 27, 28-30
26, 27, 26, 27, 26, 27, 28-30
10
|
5. (2 pts) Rearrange the following output into proper order for the above program. There are two mistakes.
main completed
[Start Thread 1]
{Working Thread 1 <b>}
{Working Thread 1 <a>}
{Working Thread 1 <c>}
[Start Thread 2]
[Start Thread 3]
[Completed Thread 1]
{Working Thread 2 <a>}
{Working Thread 2 <b>}
{Working Thread 3 <a>}
{Working Thread 2 <c>}
[Completed Thread 2]
{Working Thread 3 <b>}
{Working Thread 3 <c>}
[Completed Thread 3]
|
main completed
[Start Thread 1]
{Working Thread 1 <a>}
{Working Thread 1 <b>}
{Working Thread 1 <c>}
[Start Thread 2]
[Start Thread 3]
[Completed Thread 1]
{Working Thread 2 <a>}
{Working Thread 2 <b>}
{Working Thread 2 <c>}
[Completed Thread 2]
{Working Thread 3 <a>}
{Working Thread 3 <b>}
{Working Thread 3 <c>}
[Completed Thread 3]
|