2023 Aug CD short q's

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

encourage image

There's no tags or description

Looks like no tags are added yet.

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

No analytics yet

Send a link to your students to track their progress

7 Terms

1
New cards

What is the purpose of a synchronized block?

A synchronized block guarantees mutual exclusion and visibility between threads.

2
New cards
What is the similarity between sleep() and yield()?
Both let a thread pause without releasing its locks, and neither blocks on a condition.
3
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.
4
New cards
What happens to an object's references during serialization?
When you serialise an object, its references get serialised too, but only if they're also Serialisable, otherwise you get a NotSerialisableException.
5
New cards
What's the difference between run() and start() on a Thread?
run() just calls the method on the current thread. start() creates a new thread and has the JVM call run() on it.
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
What is the difference between a Predicate and a Function?
A Predicate's test() always returns a boolean. A Function's apply() can return any type.