Friday Java Quiz: Can Your Thread Withstand My Interruption
It has been 1267 days since Java Concurrency in Practice was published. I trust that all self-respecting Java programmers have read the book cover-to-cover. Today's Friday Quiz is a concurrency one.
Q: Will the following Java class compile? Run without exceptions? If so, what does it print?
import java.util.concurrent.BlockingQueue; import java.util.concurrent.LinkedBlockingQueue; public class Foo { public static void main(String[] args) throws InterruptedException { BlockingQueue<Integer> q = new LinkedBlockingQueue<Integer>(); q.put(1); Thread.currentThread().interrupt(); System.out.println(q.take()); } }
Strict rules apply: No actual compiling, peeking into the book, or surfing the web for Javadocs or other clues is allowed for the first 30 minutes.
Bonus Q: How many authors are named on the cover of Java Concurrency in Practice? Name three of them.
Bonus QQ: Name the other three.