NEW CD SET 4

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

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 9:36 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

14 Terms

1
New cards
What is the difference between notify() and notifyAll()?
notify() wakes one random thread. notifyAll() wakes every waiting thread, and they compete for the lock.
2
New cards
What does the volatile keyword guarantee, and what doesn't it guarantee?
volatile makes sure every thread sees the latest value, but it doesn't make things like x++ atomic.
3
New cards

What's the difference when using a binary semaphore instead of a lock?

A binary semaphore has no ownership check, so any thread can release it. A ReentrantLock only lets the owner unlock.

4
New cards
How many methods does the Externalizable interface have?
Externalizable has two methods: writeExternal() and readExternal().
5
New cards
Why do static and instance variables together complicate concurrent access?

A synchronized instance method locks the object; a synchronized static method locks the class, so they don't protect each other.

6
New cards

What is the difference between CountDownLatch and CyclicBarrier?

A CountDownLatch counts down once and can't reset. A CyclicBarrier lets threads meet up repeatedly and resets automatically.

7
New cards
How is it determined which thread wakes up when notify() is called?

The JVM decides,it's not guaranteed to be FIFO or based on priority.

8
New cards
Why is concurrent programming hard to debug?
Bugs depend on thread timing, so a program can run fine for ages then fail unpredictably.
9
New cards
How does a fair lock affect waiting threads? Give an example.
If five threads call lock() one after another, a fair lock lets them through in that same order.
10
New cards
What is a cyclic barrier? Give an example of when you'd use one.
Three threads could each fill a third of an array, call await(), then all proceed once everyone's done.
11
New cards

3 processes share 4 resource units, max 2 each — show deadlock cannot occur.

Worst case: all 3 hold 1 unit and wait for a 2nd. only 3 of 4 units used, 1 spare. Circular wait cant happen because the spare can be given to a waiting process

12
New cards

Explain drawbacks of using parallel streams, list two

they run slower on small datasets due to the extra work of splitting and join tasks. They can cause data errors if you modify shared variables or require strict processing order.

13
New cards

Explain how a server socket can prevent over threading and improve performance.

A thread pool caps how many threads handle connections at once, so extra clients queue instead of spawning new threads

14
New cards

What are the benefits of immutable streams?

A stream never modifies its source, so its inherently thread safe to read from.