1/13
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai | Chat |
|---|
No analytics yet
Send a link to your students to track their progress
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.
A synchronized instance method locks the object; a synchronized static method locks the class, so they don't protect each other.
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.
The JVM decides,it's not guaranteed to be FIFO or based on priority.
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
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.
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
What are the benefits of immutable streams?
A stream never modifies its source, so its inherently thread safe to read from.