Part1 Threading Interview Questions and Answers

1) What is Daemon thread ?

Daemon thread are background threads which are used for background task. JVM do not care for background thread execution. Once all other non Daemon threads completes their executions and JVM ends without caring for the running Daemon threads.
One can make a non-daemon thread a daemon thread using the .setDaemon(true) method.
One can check thread is daemon or not using the isDaemon() method.
Mostly JVM creates daemon threads for Garbage collection related background task.

2) What is Mutex ?

Mutex are used to serialise access of a particular section of code that cannot be executed simultaneously  by more than one thread. A mutex object only allows one thread into a controlled code area, It force other threads which are attempting to gain access to that controlled section to wait until the first thread is exited from that controlled section.