From b94e61a11a492c0635a23bad583422f6c456b088 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Fri, 6 Oct 2023 12:49:19 +0800 Subject: [PATCH 01/10] Committed on or around 2023/10/06 --- Chapter11/Creating_a_Thread_annotated.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Chapter11/Creating_a_Thread_annotated.java b/Chapter11/Creating_a_Thread_annotated.java index 6b97a51..78e9777 100644 --- a/Chapter11/Creating_a_Thread_annotated.java +++ b/Chapter11/Creating_a_Thread_annotated.java @@ -17,7 +17,8 @@ public static void main(String[] args) { // To create another thread from within the main thread, construct a MyThread object first. - + // You create a thread by instantiating an object of type Thread whose constructor encapsulates an object + // that is runnable. Thread newtThread = new Thread(); // newtThread.setContextClassLoader(myThread2023); From e196a8a2cdb444e7a96587617952e4d5c16f1396 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Fri, 6 Oct 2023 12:58:30 +0800 Subject: [PATCH 02/10] Committed on or around 2023/10/06 --- Chapter11/Creating_a_Thread_annotated.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter11/Creating_a_Thread_annotated.java b/Chapter11/Creating_a_Thread_annotated.java index 78e9777..0827ac7 100644 --- a/Chapter11/Creating_a_Thread_annotated.java +++ b/Chapter11/Creating_a_Thread_annotated.java @@ -1,4 +1,4 @@ -// To create a new thread, your program will either extend Thread or implement the Runnable interface. +// Java defines two ways in which you can create a runnable object. class MyThread202310 implements Runnable{ public void run() { From 25127f5fa940840623ddd2a7b89db9bd6d71d74b Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Fri, 6 Oct 2023 13:07:51 +0800 Subject: [PATCH 03/10] Committed on or around 2023/10/06 --- Chapter11/Creating_a_Thread_annotated.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Chapter11/Creating_a_Thread_annotated.java b/Chapter11/Creating_a_Thread_annotated.java index 0827ac7..09cad33 100644 --- a/Chapter11/Creating_a_Thread_annotated.java +++ b/Chapter11/Creating_a_Thread_annotated.java @@ -1,4 +1,5 @@ // Java defines two ways in which you can create a runnable object. +// You can implement the Runnable interface or you can extend the Thread class. class MyThread202310 implements Runnable{ public void run() { From 68e20484d6155260ab3a56c12e0350ebd4f681d0 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Fri, 6 Oct 2023 14:05:01 +0800 Subject: [PATCH 04/10] Committed on or around 2023/10/06 --- Chapter11/Creating_a_Thread_annotated.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Chapter11/Creating_a_Thread_annotated.java b/Chapter11/Creating_a_Thread_annotated.java index 09cad33..132bcf8 100644 --- a/Chapter11/Creating_a_Thread_annotated.java +++ b/Chapter11/Creating_a_Thread_annotated.java @@ -1,6 +1,14 @@ -// Java defines two ways in which you can create a runnable object. +// Java defines two ways in which you can create a runnable object: // You can implement the Runnable interface or you can extend the Thread class. class MyThread202310 implements Runnable{ + + String thread_nameString; + + public MyThread202310(String thread_nameString) { + + this.thread_nameString = thread_nameString; + + } public void run() { From 5944dc70c59245450e37c7523dd2dacf40079f16 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Fri, 6 Oct 2023 14:08:24 +0800 Subject: [PATCH 05/10] Committed on or around 2023/10/06 --- Chapter11/Creating_a_Thread_annotated.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Chapter11/Creating_a_Thread_annotated.java b/Chapter11/Creating_a_Thread_annotated.java index 132bcf8..e06281e 100644 --- a/Chapter11/Creating_a_Thread_annotated.java +++ b/Chapter11/Creating_a_Thread_annotated.java @@ -12,6 +12,7 @@ public MyThread202310(String thread_nameString) { public void run() { + System.out.println(thread_nameString + " starting."); } From 3fa694aac9053fc46979d8e24cca5c4499ace06a Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Fri, 6 Oct 2023 14:11:34 +0800 Subject: [PATCH 06/10] Committed on or around 2023/10/06 --- Chapter11/Creating_a_Thread_annotated.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter11/Creating_a_Thread_annotated.java b/Chapter11/Creating_a_Thread_annotated.java index e06281e..0312dcb 100644 --- a/Chapter11/Creating_a_Thread_annotated.java +++ b/Chapter11/Creating_a_Thread_annotated.java @@ -25,7 +25,7 @@ public class Creating_a_Thread_annotated { public static void main(String[] args) { System.out.println("Main thread starting."); - // To create another thread from within the main thread, construct a MyThread object first. + // Create a runnable object. MyThread202310's object is runnable because it has run() method. // You create a thread by instantiating an object of type Thread whose constructor encapsulates an object // that is runnable. From 99ccd3b10b88c21bdd3df3dde8b2a2cddb6db5a9 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Fri, 6 Oct 2023 14:17:27 +0800 Subject: [PATCH 07/10] Committed on or around 2023/10/06 --- Chapter11/Creating_a_Thread_annotated.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Chapter11/Creating_a_Thread_annotated.java b/Chapter11/Creating_a_Thread_annotated.java index 0312dcb..2d84e53 100644 --- a/Chapter11/Creating_a_Thread_annotated.java +++ b/Chapter11/Creating_a_Thread_annotated.java @@ -26,6 +26,7 @@ public static void main(String[] args) { System.out.println("Main thread starting."); // Create a runnable object. MyThread202310's object is runnable because it has run() method. + MyThread202310 myThread202310 = new MyThread202310("Child #1"); // You create a thread by instantiating an object of type Thread whose constructor encapsulates an object // that is runnable. From 8be0c49b2392771df2a3ab5fdde74b64f9d9e0a2 Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Fri, 6 Oct 2023 14:22:32 +0800 Subject: [PATCH 08/10] Committed on or around 2023/10/06 --- Chapter11/Creating_a_Thread_annotated.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter11/Creating_a_Thread_annotated.java b/Chapter11/Creating_a_Thread_annotated.java index 2d84e53..46eb920 100644 --- a/Chapter11/Creating_a_Thread_annotated.java +++ b/Chapter11/Creating_a_Thread_annotated.java @@ -30,7 +30,7 @@ public static void main(String[] args) { // You create a thread by instantiating an object of type Thread whose constructor encapsulates an object // that is runnable. - Thread newtThread = new Thread(); + Thread newtThread = new Thread(myThread202310); // newtThread.setContextClassLoader(myThread2023); } From ed0be9ed047cac91a61fbad9b6165d21f22d1d3d Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Fri, 6 Oct 2023 14:31:17 +0800 Subject: [PATCH 09/10] Committed on or around 2023/10/06 --- Chapter11/Creating_a_Thread_annotated.java | 1 + 1 file changed, 1 insertion(+) diff --git a/Chapter11/Creating_a_Thread_annotated.java b/Chapter11/Creating_a_Thread_annotated.java index 46eb920..dc8ec8c 100644 --- a/Chapter11/Creating_a_Thread_annotated.java +++ b/Chapter11/Creating_a_Thread_annotated.java @@ -10,6 +10,7 @@ public MyThread202310(String thread_nameString) { } + // Inside run(), you will define the code that constitute a thread. main() is a thread, too. public void run() { System.out.println(thread_nameString + " starting."); From bbe597b125279888c2b419b035759703d8eac8cd Mon Sep 17 00:00:00 2001 From: Ceiling_roof <48134466+ResilientSpring@users.noreply.github.com> Date: Fri, 6 Oct 2023 14:38:03 +0800 Subject: [PATCH 10/10] Committed on or around 2023/10/06 --- Chapter11/Creating_a_Thread_annotated.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter11/Creating_a_Thread_annotated.java b/Chapter11/Creating_a_Thread_annotated.java index dc8ec8c..311e08f 100644 --- a/Chapter11/Creating_a_Thread_annotated.java +++ b/Chapter11/Creating_a_Thread_annotated.java @@ -10,7 +10,7 @@ public MyThread202310(String thread_nameString) { } - // Inside run(), you will define the code that constitute a thread. main() is a thread, too. + // Inside run(), you can write some code that constitutes a thread. main() is a thread, too. public void run() { System.out.println(thread_nameString + " starting.");