Skip to content

Commit 01e2439

Browse files
committed
Refactor code and notes for daemon threads
1 parent 037b398 commit 01e2439

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Simple and easy to understand code examples for most of the Concurrent APIs prov
1414
- [Thread States](./notes/thread-states.md) - [[code](./src/com/codecafe/concurrency/thread/basics/designathread/ThreadStates.java)]
1515
- [Thread Termination](./src/com/codecafe/concurrency/thread/basics/Main.java)
1616
- [Thread Signalling](./src/com/codecafe/concurrency/threadsignalling)
17-
- [Daemon Thread](./notes/daemon-thread.md) - [[code](./src/com/codecafe/concurrency/thread/daemonthread)]
17+
- [Daemon Threads](./notes/daemon-threads.md) - [[code](./src/com/codecafe/concurrency/thread/daemonthreads)]
1818

1919
#### Thread synchronization and locks
2020
- [The `synchronized` keyword](./src/com/codecafe/concurrency/_synchronized)

notes/daemon-thread.md renamed to notes/daemon-threads.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
## Daemon Thread
1+
## Daemon Threads
22

3-
> A **Daemon thread** is a low priority thread that runs in background to perform housekeeping tasks such as garbage collection.
3+
> **Daemon threads** are low priority threads that run in background to perform housekeeping tasks such as garbage collection.
4+
> They are background threads that do not prevent the application from exiting if the `main` thread terminates.
45
56
#### Properties:
67

src/com/codecafe/concurrency/thread/daemonthread/DaemonThread.java renamed to src/com/codecafe/concurrency/thread/daemonthreads/Main.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package com.codecafe.concurrency.thread.daemonthread;
1+
package com.codecafe.concurrency.thread.daemonthreads;
22

3-
public class DaemonThread {
3+
public class Main {
44

55
public static void main(String[] args) {
66
// Daemon thread
77
Thread th = new Thread(() -> {
8-
for (int i = 1; ; i++)
8+
for (int i = 1; i <= 10000; i++)
99
System.out.print(" D-" + i);
1010
});
1111

0 commit comments

Comments
 (0)