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/12

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 8:49 PM on 8/4/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai
Chat

No analytics yet

Send a link to your students to track their progress

13 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, 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 waste more context-switching than working and too many threads can exhaust memory for stacks. Use a bounded pool instead.

7
New cards

What is a monitor?

A monitor gives one thread exclusive access to an object’s data by tying a lock to the object. entering a synchronised method acquires it and other threads block and queue until it’s released.

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

How can a reentrantlock be fair?

new ReentrantLock(true) gives the lock to the longest-waiting thread first, at the cost of some throughput.

11
New cards

Name three ways processes on the same processor can communicate. If any require hardware support,

  • Shared memory: processes share the same physical memory via the MMU, but still needs a semaphore for coordination.

  • Message passing: the OS copies messages between processes, no hardware needed.

  • Semaphore: OS provided coordination, built on hardware atomic instruction like compare and swap

12
New cards

Explain what is meant by encapsulated classes.

Encapsulation bundles a class’s data with the methods that operate on it, while hiding the internal state from the outside

13
New cards