From the course: Parallel and Concurrent Programming with Java 1
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Daemon thread - Java Tutorial
From the course: Parallel and Concurrent Programming with Java 1
Daemon thread
- We often create threads to provide some sort of service, or perform a periodic task in support of the main program. A common example of that is garbage collection. A garbage collector is a form of automatic memory management that runs in the background and attempts to reclaim garbage, or memory that's no longer being used by the program. Many languages include garbage collection as a standard part of their run time environment, but for this demonstration, I'll spawn my own new thread to handle garbage collection. - Man, what a mess. - Olivia is a separate child thread that will execute independently of my main thread. So, I can continue doing what I'm doing here, getting my soup ingredients ready. - While I try to reclaim some memory, or counter space, by clearing out Baron's garbage. - This set-up, with Olivia running as a separate thread to provide that garbage collection service, will work fine until I'm ready to finish executing. Bam, now my soup's spiced and ready, my main…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Thread vs. process4m 36s
-
Thread vs. process: Java demo6m 48s
-
(Locked)
Concurrent vs. parallel execution4m 54s
-
(Locked)
Execution scheduling3m 38s
-
(Locked)
Execution scheduling: Java1m 57s
-
(Locked)
Thread lifecycle3m 36s
-
(Locked)
Thread lifecycle: Java demo4m 55s
-
(Locked)
Thread attributes: Java demo2m 22s
-
(Locked)
Runnable vs. thread: Java demo3m 53s
-
(Locked)
Daemon thread2m 49s
-
(Locked)
Daemon thread: Java demo2m 21s
-
-
-
-
-