You are on page 1of 4

2/16/23, 6:28 PM H CS 3 - Multithreading Exercise 2

H CS 3 - Multithreading Exercise 2
Total points 9/9

The respondent's email (krithika.subraman.1@mypisd.net) was recorded on submission of


this form.

Name in format Last, First: *

Subramanian, Krithika

Period: *

3rd

4th

Start of the Exercise

When using a lock, all of the work of the method should be done in a try *1/1
clause after lock() is called in order for the object to be properly
protected.

1. True

2. False

https://docs.google.com/forms/d/e/1FAIpQLScFRVbGm4Bx1zITYasUEIAA4_ktjQm5zAS0NyWsifXgHv5f7g/viewscore?viewscore=AE0zAgAxcNna… 1/4
2/16/23, 6:28 PM H CS 3 - Multithreading Exercise 2

Deadlock occurs when * 1/1

all of the threads are asleep

all of the threads try to run at the same time

you run out of memory

all threads are waiting on other threads to do some work

Where should the unlock() method be called? * 1/1

anywhere after the lock() method is called

in a finally clause so that it gets executed even if there is an exception thrown

it doesn’t have to be called

the call must be the last statement in the method

Which Condition method should be called when a condition has been met *1/1
that might allow waiting threads to proceed?

await

signalAll

conditionMet

retry

https://docs.google.com/forms/d/e/1FAIpQLScFRVbGm4Bx1zITYasUEIAA4_ktjQm5zAS0NyWsifXgHv5f7g/viewscore?viewscore=AE0zAgAxcNna… 2/4
2/16/23, 6:28 PM H CS 3 - Multithreading Exercise 2

What kind of object should be used to control the threads that want to *1/1
manipulate a shared resource?

Condition

Lock

Interrupt

PhoneBooth

What object should be used to avoid deadlock? 1/1

Condition

Lock

Interrupt

It cannot be avoided

Race conditions occur when * 1/1

multiple threads are accessing the same object at the same time

multiple threads are performing math at the same time

multiple threads are running at the same time.

multiple threads are printing at the same time

https://docs.google.com/forms/d/e/1FAIpQLScFRVbGm4Bx1zITYasUEIAA4_ktjQm5zAS0NyWsifXgHv5f7g/viewscore?viewscore=AE0zAgAxcNna… 3/4
2/16/23, 6:28 PM H CS 3 - Multithreading Exercise 2

The wait() method causes the current thread to wait, and allows another *1/1
thread access to the lock.

1. True

2. False

Conditions objects are "created"/called on Lock references. * 1/1

1. True

2. False

This form was created inside of Plano ISD.

 Forms

https://docs.google.com/forms/d/e/1FAIpQLScFRVbGm4Bx1zITYasUEIAA4_ktjQm5zAS0NyWsifXgHv5f7g/viewscore?viewscore=AE0zAgAxcNna… 4/4

You might also like