Java Threading interview questions
Atomic Variables, ExecutorService, Race Conditions, Synchronized and Locks, The Volatile Keyword, Virtual Threads
62 questions with answers and explanations · 62 flashcards
Questions (page 2 of 2)
- How does CompletableFuture help in managing asynchronous computations?Multiple choiceMedium
- How do Virtual Threads affect the performance of CPU-bound tasks compared to I/O-bound tasks?Multiple choiceMedium
- Which Java version introduced Virtual Threads as part of Project Loom?Multiple choiceEasy
- What happens if you call shutdownNow() on an ExecutorService?Multiple choiceMedium
- In which scenario would a ScheduledThreadPoolExecutor be preferred over a FixedThreadPool?Multiple choiceHard
- How does the JVM manage Virtual Threads during a blocking network I/O operation?Multiple choiceHard
- How does the ExecutorService improve task management over using raw Threads?Multiple choiceMedium
- What happens to tasks submitted to an ExecutorService after shutdown() is called?Multiple choiceEasy
- What happens when a CompletableFuture executes a task on a virtual thread?Multiple choiceHard
- What could be a potential downside of using a CachedThreadPool for handling a large number of short-lived tasks?Multiple choiceHard
- Which of the following Java constructs can be used to execute tasks using Virtual Threads?Multiple choiceMedium
- What does volatile actually guarantee in Java?Multiple choiceEasy