Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
What is the result?
A. A done
B. B done
C. A done
B done
D. B done
A done
E. There is no exception that the application will print anything.
F. The application outputs “A done” and “B done”, in no guaranteed order.
Daemon threads only run as long as there are User Threads (non-daemon threads) running.
Once you start thread A in the main method, the 'main thread' (which is the only remaining user thread) ends. At that point the JVM shuts down the daemon thread. This happens before Thread A has the opportunity to print its own output or create thread B.
If you comment out the setDaemon() line, you will probably see it prints out the output lines for both A & B threads. In that situation, you are not creating a Daemon thread. Both A & B are user threads.