Flashcards

Quick study sessions to strengthen memory and retain key concepts.

Flashcard Study

Java: Synchronized and Locks

Front

Why is it crucial to release locks in a finally block?

To prevent lock leaks. Frame the concept in practical terms so you can explain it during interview discussion.…

View Card →
Flashcard Study

Java: Synchronized and Locks

Front

What role does 'synchronized' play in Java concurrency?

It ensures mutual exclusion. Frame the concept in practical terms so you can explain it during interview discussion.…

View Card →
Flashcard Study

Java: Concurrent Collections

Front

Describe the performance impact of lock striping?

It improves throughput by reducing contention. Lock striping enhances performance by dividing locks across segments, allowing multiple threads…

View Card →
Flashcard Study

Java: Concurrent Collections

Front

What happens if a key is modified during iteration in ConcurrentHashMap?

The result is undefined; it may not reflect changes. Modifying a key during iteration in ConcurrentHashMap can lead…

View Card →
Flashcard Study

Java: Concurrent Collections

Front

How does lock striping reduce contention in ConcurrentHashMap?

By locking only parts of the map. Frame the concept in practical terms so you can explain it…

View Card →
Flashcard Study

Java: Concurrent Collections

Front

Can ConcurrentHashMap handle null keys or values?

No, it does not allow null keys or values. ConcurrentHashMap does not permit null keys or values to…

View Card →
Flashcard Study

Java: Concurrent Collections

Front

Why is ConcurrentHashMap preferable in high-concurrency scenarios?

It allows high concurrency without global locking. ConcurrentHashMap achieves high concurrency by reducing global locking, allowing multiple threads…

View Card →
Flashcard Study

Java: Concurrent Collections

Front

What error can occur with a HashMap under concurrent modification?

ConcurrentModificationException or infinite loops. If a HashMap is modified concurrently by multiple threads, it can throw a ConcurrentModificationException…

View Card →
Flashcard Study

Java: Concurrent Collections

Front

How would you explain a tradeoff when using Collections.synchronizedMap in an interview?

Global locking can cause performance bottlenecks. While Collections.synchronizedMap ensures thread safety by locking the entire map, this can…

View Card →
Flashcard Study

Java: Concurrent Collections

Front

How does ConcurrentHashMap achieve high concurrent throughput?

It uses lock striping to minimize contention. ConcurrentHashMap divides the map into segments, each independently locking only a…

View Card →