NEW CD SET 3

0.0(0)
Studied by 0 people
call kaiCall Kai
Locked
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/9

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 7:14 PM on 7/7/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

10 Terms

1
New cards
What is the difference between wait() and sleep()?
wait() releases the lock and needs notify() to wake up. sleep() keeps its locks and wakes up on its own.
2
New cards
What's the difference between deadlock prevention and deadlock avoidance?
Prevention removes a condition outright, like a fixed lock order. Avoidance checks at runtime if granting a resource could cause deadlock.
3
New cards
What is the semantics of a counting semaphore?
acquire() decrements the permit count, or blocks if it's zero. release() increments it and wakes a waiting thread.
4
New cards
What is object serialization, and how do you implement it?
Serialization turns an object's state into bytes. Implement it via Serializable, a marker interface, or Externalizable, which needs writeExternal() and readExternal().
5
New cards
What is resource ordering, and why does it prevent deadlock?
Every thread acquires locks in the same fixed order, which stops a circular wait from forming.
6
New cards
Why is overuse of threads bad?
Too many threads mean more context-switching and more memory for stacks — use a bounded pool instead.
7
New cards
What is a monitor?
A monitor, like Java's synchronized, gives one thread exclusive access at a time, with a queue for the rest.
8
New cards
What are the three functions/purposes of synchronization in Java?
Synchronization gives mutual exclusion, visibility between threads, and ordering, so instructions aren't reordered across the boundary.
9
New cards
Can a constructor be synchronized? Why or why not?
No — the object isn't visible to other threads until construction finishes, so there's nothing to lock yet.
10
New cards
What is a fair lock, and how do you create one?
new ReentrantLock(true) gives the lock to the longest-waiting thread first, though it costs some throughput.