Skip to content
Sharp

Engineering Interviews · interview question

Why is spawning new threads directly inside a Java controller considered a bad practice?

Multiple choiceMediumchapter-20-curatedpremiumengineering-interviewscode-review-spotting-bugs
java
new Thread(() -> { /* task */ }).start();
Choose one answer
Answer and explanation

Correct answer

B. It can cause memory leaks.

Why

Spawning threads in controllers can lead to resource leaks and inefficient use of resources. Using a thread pool, like Executors, provides better management and performance.

Test yourself on Engineering Interviews

A free test with instant, explained results. No account needed.

Start free test
All Engineering Interviews questions →