From 2ec1a0336d665f986a471e50387c24c1901bdd80 Mon Sep 17 00:00:00 2001 From: Nikola Date: Mon, 11 Jul 2022 10:52:18 +0300 Subject: [PATCH] Added Threads --- .idea/modules.xml | 1 + 60-TimeTask/60-TimeTask.iml | 2 +- 61-Threads/61-Threads.iml | 13 ++++++ 61-Threads/out/production/Main.class | Bin 0 -> 692 bytes 61-Threads/out/production/MyThread.class | Bin 0 -> 588 bytes 61-Threads/src/Main.java | 53 +++++++++++++++++++++++ 61-Threads/src/MyThread.java | 12 +++++ 7 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 61-Threads/61-Threads.iml create mode 100644 61-Threads/out/production/Main.class create mode 100644 61-Threads/out/production/MyThread.class create mode 100644 61-Threads/src/Main.java create mode 100644 61-Threads/src/MyThread.java diff --git a/.idea/modules.xml b/.idea/modules.xml index 0c8d48f..a55bb66 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -63,6 +63,7 @@ + diff --git a/60-TimeTask/60-TimeTask.iml b/60-TimeTask/60-TimeTask.iml index 1422788..e320686 100644 --- a/60-TimeTask/60-TimeTask.iml +++ b/60-TimeTask/60-TimeTask.iml @@ -1,7 +1,7 @@ - + diff --git a/61-Threads/61-Threads.iml b/61-Threads/61-Threads.iml new file mode 100644 index 0000000..f2b840e --- /dev/null +++ b/61-Threads/61-Threads.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/61-Threads/out/production/Main.class b/61-Threads/out/production/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..a8f7fce03bf9ee3deba619e5cf12f966dac5bb54 GIT binary patch literal 692 zcmZvZ+iuf95QhKF$+2;1Y1$NMDU@TG%Xk#L?H{Xw z5vV-Tu{O^Hij8K^K~g>Gcp@F^l%N=9jyD69jiCfsIStl?2mb~93}%f?#WbJ z`|oAR9O;Z(32kzl*-;LuH$Kcq$aly7bv$Y}d-Th6#Q53;ZtlzEd+dHr1ibKUt)zM{ zzYNsG=p@b@1Ol7q@A5h}Dov*oqlW*2n9xb4=|H{GwsF_?wqsMUgCPvgxKVd)E2t&1J3(XxM8a}gZB-WTQjW8 zaFy!DIkV2PAhC*FEMO07*vC2^=QZkc4w~3zOcg6=;UVijqE({a;o0SX0egP{s4t4D literal 0 HcmV?d00001 diff --git a/61-Threads/out/production/MyThread.class b/61-Threads/out/production/MyThread.class new file mode 100644 index 0000000000000000000000000000000000000000..cb4f7247a12fde9f6c1e4b4932f44bef160cf797 GIT binary patch literal 588 zcmZvZ%}&BV6ot<~p`{eTBBJ0A{svgs2SD9uT!Arxu+Y^24U9rdN^8QS_yn$Xfr$$r zz=ty4DPS})Y46;bIrlqvWZH%cluUq;MuI+@; z@Xr~d-2f(0?C2mOF;`#KnPY_G*TLs~KGZkG?++!J!XSX6xK zl0mO8ucAgr^8zwXHGSTFXz=kusW;ug>)KaBvQkU=iEJNxbgvP55m03EDJX8!%%YLe z7^}X4y@cC46y-MP-=%2G1t<|juI>L6--R%sSe-$A!pbXBW_E_$Gm 0; i--) { + System.out.println(i); + Thread.sleep(1000); + } + System.out.println("Done!");*/ + + MyThread threadTwo = new MyThread(); + //threadTwo.start(); + //threadTwo.run(); - status is false + //System.out.println(threadTwo.isAlive()); + //threadTwo.setName("Thread Two"); + //System.out.println(threadTwo.getName()); + //it will inherit the priority of the thread that created it + //System.out.println(threadTwo.getPriority()); + + //threadTwo.setPriority(1); + + //System.out.println(Thread.activeCount()); + threadTwo.setDaemon(true); + System.out.println(threadTwo.isDaemon()); + threadTwo.start(); + + } +} diff --git a/61-Threads/src/MyThread.java b/61-Threads/src/MyThread.java new file mode 100644 index 0000000..3503a4b --- /dev/null +++ b/61-Threads/src/MyThread.java @@ -0,0 +1,12 @@ +public class MyThread extends Thread { + + @Override + public void run() { + if (this.isDaemon()) { + System.out.println("This is a Daemon thread"); + } else { + System.out.println("This is user thread"); + } + } + +}