Quiz 7
Explore key concepts in Java multithreading through quiz questions that highlight issues in thread creation within constructors and explain stack confinement for thread safety. Understand why starting threads in constructors can be unsafe and learn how local variables contribute to thread confinement.
We'll cover the following...
We'll cover the following...
Question # 1
Can you enumerate the implications of the poor design choice for the below class?
public class BadClassDesign {
private File file;
public BadClassDesign() throws InterruptedException {
Thread t = new Thread(() -> {
System.out.println(this.file);
});
t.start();
t.join();
}
}