From faaf159f04009f13026ce1e8dcfa72fd07333935 Mon Sep 17 00:00:00 2001 From: michelefiori Date: Fri, 1 Mar 2024 16:13:08 +0100 Subject: [PATCH] Minor changes on comments --- build/classes/java/main/join/Main.class | Bin 1569 -> 1560 bytes build/classes/java/main/join/MyThread.class | Bin 908 -> 902 bytes .../java/main/producerConsumer/Consumer.class | Bin 1090 -> 1401 bytes .../java/main/producerConsumer/Main.class | Bin 982 -> 982 bytes .../java/main/producerConsumer/Producer.class | Bin 1504 -> 1801 bytes .../java/main/producerConsumer/Queue.class | Bin 1122 -> 1116 bytes build/classes/java/main/semaphore/Main.class | Bin 1320 -> 1308 bytes .../java/main/semaphore/MyThread.class | Bin 1606 -> 1816 bytes .../java/main/semaphore/Semaphore.class | Bin 1167 -> 1378 bytes src/main/java/join/Main.java | 5 ++++- src/main/java/semaphore/Main.java | 5 +++-- src/main/java/semaphore/MyThread.java | 14 +++++++++----- src/main/java/semaphore/Semaphore.java | 17 +++++++++++------ 13 files changed, 27 insertions(+), 14 deletions(-) diff --git a/build/classes/java/main/join/Main.class b/build/classes/java/main/join/Main.class index 2946019686eaf577e2b43de45880ddb9d13335a0..2ae0d963ee70256e5cb64139da6cf3db2c71dfd7 100644 GIT binary patch delta 845 zcmah`OHWfl6#l07w$lz%sVyLHEuvB=T)`JY#RqSpAP+%M7T0nkmtd>y#b8`C8dq*i zyc=EWhK&nx0nsMLwg1Az=-MqI;29bkJ3S0qQ*4IA@BULG|Ew%|9#u1LFL<5exZ?#ULN*t3ojuY-Ttuax87@9d+ zB;sgg2>*R_*s-#vlgTphB{Mf>t&u!ZHLngljocs$F^K-Ply%Rs zGwB@1ylZHcc`=n)&8DmYd&MF`lCW*6dqi=G{z)wl=ymw$yh4#dmXY-~Z-H&>U-#0f zu0cQ4N2e?T(2oI%0vN;)6(KUa4~Q3#DCp zyh`6hc=oBr*7v@@M@6`H6ZP>;G>)}?Koi3&RFKog@EILlx&ohG-}|9}=Lo3m`Tr5R z*Y`sEj2=QNEjoJLgm)ybR1A@t2HL~8O8GGAFoIF){~9SsVvKT+|9GSb<8%Y~@eC7~ zqzQ!Z1XGwM<<}{%W>U<|P-d1gQTTQd=HMKHZKHMvk|VZ_njO@X6+PS_oKDO++BeDf G;MOk^Je;op delta 840 zcmah`O-~b16g_V`?VAn{TMHH_UxKK76e@y>fK@~gr7Z{u7C%Qiks;V>I~Z71jVluu zbvC-x4Qn)kD2XvH{S7W$>3<*uypQ^^bdvY(xo7T~d(WL$;*H3E-TC+lKsWB_2;wBi zDIJQ8JvvkwPwViYS0;U4^y7?%sE)HZCz*i~oX4QNE^rL#@L^cPMGYeoUea)xW0WJt z;OV#0mK|kqHMdMNsDqi5$>57w@4qO0EKgmjAxE4+A6lL>AJ|qVo#RMQKABm{&Y8p3 zA_=^4!%BB77>^8r3RE)qC5|lF)?#GBNT)LQ8Or`q1KF&x60>qPL+L`sN=M==Q}bEV zNJ;gWz&NgOObECpG3EGKLx|(5z%*tAt|3X|2+ZQTzzy7Vm{R5zxP?k8tkQC}k+scK zhZ9%AMBgU*g%YZ#35$Jb%s;~|8tHqHvAYZAob9Z!3dg4g3x!}|t*-E`(}}Vk=P_&Y zGw^vMmoS%UR9exj^PSb@8Qgn)XkYTHXutvbMeGU~7A?Lv(xg zNRDd4qF8_$)Kca}9qQ>LBxVocf}6OPn^2M)aK$#EQgp{%`Dm?Qe~Zv2Jju2V@Ln}s zrLIGpdFEoPyFcE+8_?HL5?+T$w0}S;!)pWy>|^*0U#}{Q{j0k_W#N7*lriu>LD_FX zIW;PgUQ~pfF863&x)=dRBb|e^3KaqJ(uhMe|2R2l!eQc`{6*vlM{tx>8lIyWEwlkY zo}v|PV_T@%hT!PjLiIMP%ZmudsZJ$j7oBdx3Qqh2 DiD;NG diff --git a/build/classes/java/main/join/MyThread.class b/build/classes/java/main/join/MyThread.class index dff7bcaab0e7f2ef5971449a0b71b8c0525d51cf..168cc296e629ae37d7f503beb85e8b1c59d08d52 100644 GIT binary patch delta 543 zcmYL_&rTCj6vlsdX4*R)r=X||`H#s@qIp24_bM8m|L3h6Y{`w7Q(Q+^_HI_??v?9Of zzxJC4e)Oujy*mi}o+8~2qcDD=Fsrpr2Ahn=ak+%6$nG76QFH6!d(#d2ad;RxEK+r;CAUoV2VoSyi2d&V_Q3B3Hp`0K zKigg?p2MB};g5|`UX|WamfH;Z6(v!wlPp0gR-|%AvQ5EB#i^g7>dRlyClgLXVh&TH zjYUSDLsQV)Ih(tz3KAXnWU7+4M*3prv2YS)qu% z%E#DSD`S?DMqL^wBA=y%C+C_pM)T&N*+`!EYDjw!g zwYhm03m!69%%J9??&6j}D%PPuaeXg%AJn@>wd!vI9Y*`h0>djxEAv!fqVj)wZc8Bj zJPM^ieqCw#s=L1}e%YNNa^~<;pT2EgOEHTwlcb! zYsI#8%>{RC&!>mikXyYdm~;!qF6Q-##e-49>k9wD=_&_mWHSTlS~ z^f;zbB4Y}ce}+3ywY~gtvQLwtMBXyFW^oCNxSVJzvA#@|7a6m&)CTJKS7C}Zf=F;$ V=QrVwiz}4t;%b_S5)%%}e*iqgwY>lU diff --git a/build/classes/java/main/producerConsumer/Consumer.class b/build/classes/java/main/producerConsumer/Consumer.class index 8d4380cff125d333e16aad1548d4d12f19d7ddc7..7348d91d359ab31923d40a7ddb13a09bf007aa82 100644 GIT binary patch literal 1401 zcmaJ>+foxj5IvIwHmpm4K)5PK1x>;w-bEHK5Jjm9-a=tnJ`KqfEZOXa-C3&m6aT*XZ z*IT=yDjB+$EXR_M8REJ8W)G6+(V!c+0E1zy>AAI_D!h{G_(4N>#ghp`%&IY@%cp=9 z=~>RUsUT7Y`q0nNwHJs$FpQSlfZnPTQ%4$u8iovHFw8LA*^D6}d7W^Ea{2avIt3gx zFotmktr{iDkjb@MDt;GnNyDUp%gCOSqjKO&(I6GvfJDhe&X!wzL!=~86TD%jNzx8dWaeTXIL~BDo`dhJ_B1JLJ;7rQlOL!X*P`d0^xxL9fORZa*3Atkt z$%*zGJt+;7f$foyUf?kFRwS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/main/producerConsumer/Main.class b/build/classes/java/main/producerConsumer/Main.class index 7c87885d1ee0c579c875527e5f961084a20dee0c..e65e0e682846e063e95ce5ea2117952ce1eb2c9e 100644 GIT binary patch literal 982 zcmZuwU31bv6g>+G2`Oz53I(ZX{RCQyrRqa*d}wF14^VCCFfu+kA?(mF5HKV@>5uY7 zW@N@6;E!^=8_Iwa^00e$@7;6Gy}SAI_t$R#HN4aiLRf(mgNz76yl;FpDg(prRo-{{ z+;kZtuPxhh-!Oy=#g+nDUKS{>&gi2)i6}|9NY@k8$kJv;PTNp#fH^lt{&*w#;j6*uF!lSM{rxKIsQ}z*c jERWAf5DF7t6WfF&Vtt1Us-$;He{YVEXxcF`gz(}YOrzMK literal 982 zcmZuwU2oD*7=8{ES~@m1aAP>#r&Gqp&`rG<#)~b{UBLWcStPqKr8KMr3YOL@{ZZaX zB8fl1A7y+_83EJv;+*HaU*~zB^Y+i*U%vr7#|s@x$g9}X5s`aA!-ft8`x>@1Y^ylX zu%ja(4ZA9eI_7aGmy(L7DxL|%U)hfBy%vb(_pSt#vtH8@NL6gdy70RV%e^!j9a_?r zo@sQh4A++DTchIL*aLxVrSJBdzG=BFzH4EqT68ITdkg&Y$WGLv<~0h5~r7N^o&-nf?0lsU&qJ}<9a z4po+<{!4n-Xj`TyP|Sx#4$Cu^Pl}(NjsNI7j(pkRSz-gva6N2ck>e%52si=AaJ|P< ziM!w)D-0oi1ny<7@xU0x3UP8AfGk#dN+5^(v@ltuIG!qP-$#hlhlo~2Q0nQ}{t)qM z096Su0;oxNqKuHJr*-1FlURV00gjI_Uq2XP;U`iO7N;<$%;4Azj*sz_^bx7D6KJHL zA+dF$0tvr_j#JE`O8+PRFik9=j}*R96WQSTxCyM`0Z$ryJY+6M8EtG}lZvh5GZoxK dl=W)ZCQ?}SEq3sT_no4QT_P#kV^)aZ$v-~`*VzC7 diff --git a/build/classes/java/main/producerConsumer/Producer.class b/build/classes/java/main/producerConsumer/Producer.class index 6d346b3304e8c2e1f5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Ye@zP8#L#!4;e)V!*YOOD<4nnLDZc)}B;54Sv*qBH*=u1?dN zqTM#@KD|HIQFRpKnp><5XM%x_S2dOcrLsJUjT0`w?EcMRr})RLkz z%9}C9oVM$=+c)k;VmIcQMc%BBHDNB2jTfej}vg(sLbCx|-%Pvmsph E3-R;lCjbBd diff --git a/build/classes/java/main/semaphore/Main.class b/build/classes/java/main/semaphore/Main.class index 6e7db4067f6e83ba23a282637a564fab022f557d..0f9e9656816af4523b12333b30582afe6cf38686 100644 GIT binary patch delta 748 zcmYjOK~EDw6#k|=+ks(=rC6Z?wIFI+3I$P=QbAOdYQY4Jraig9#+E=!wyS|tFaCo) znRxPoS1vT##CZ1PZ!qDgKY$qPo2^7AnfK<+_q{jYd-FlQll8B^KYa!;hgAt5Gy!fv zho2$1Wxh7k+h*lu`tkafwc#-Mv*k+JnP<@AiDv>Gr=(X-c{{ykRyM0U5<(T}V(9hq zJ!sLk&Ha42=153|b`x5&cFf&Ub-}jMPufS@k_aHEp6_Ac@tk_2mm&0*O3ao0rzP7m zHzh&{E8;o#hi^ivvi$}kIPVTptEaWyNw=9so4kY?!qPpw(59KNWs z9-5e3+S{;popQBO6L{o)^YyzwSzjH)n4qz%Y4VJ`o@{^}dhirk1uJ`% ztkEW58rLZ5#C6P25lUuBuMn`_geWx7nQuapH&&Vm6hs4OR<#)(=0Umq9z#up3S(hD z-oV+6o{H#4=zIQ#vxC<6)DZ?UJifMMsnaEfFGyr`#Tz?l9V=-ZQ*Mz@*OjPc z`u|DVH*k|g3{roy$PlAI(Hyd5NfvHlo_q(2Sio&+BZxID;tt7=AcwoS2MtTaP%XBx s`-DB9n-TC9mDL571%!YU2+&AQ5c}ob#!l$pb428n`jB>>&OWUC0WqnCO#lD@ delta 739 zcmY*WT~8B16g|_^zzEeM{&%Xcpx(i?&1r^6| zSztniOXe#oxXf2ocyLW1rNWEr5}cIbMmMG~EyGQL85KU<61XjJhru&x*_JcK;Eu%? zKL2247LJlGNs^ktEQ30`xomDY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6d9m^avF%E?|pB!=gis^wBy*Z_#6>wI5#KU-yo!9DqX&>8@+?NlI)*f7-WaxM&2{~81Ka!~6Fw$FL|-=1h6<-} zfpN2#!8&u;j&zJlVg!0jEU3{UQaySoS%&U)%gB*yz?`X zJ6Dcy?J3bFd1uKQCo33F*KwZK1==t2T8tuDT%Y6GCn!g?SnS0#>9NE52;7bo$NnK% r%s`T}z`$mLZg;p4!(DvJw=Um3fTXWk)7(FXFk)z5@Vkd1%(x4V7j+4|}!Zo2lOABu8($*$Wu2t;C7TA(UmTA&= zhM&T7nZ{-4OowNF3BLk3yK>@Wn(&}+SKs}d{dWKQ=Z~iV)=;-GhqVcu#v4k!sl;10 z#oH5j2k%-~w_#x|jSaQFr^KZ+-dF1fHa^5<8&~jA8duY}rnVp3_yi@D^ty!`HfB+_ zP_b}Rz>I>1K(_pY_mfxb$9}tb#|s)^XI;SXX%Qv*^khe1w#>!rw!%mjt9v`Tjc@pY zA72t!&Oe)_bY#%dramn9L!_E!C5Ri zSVqCZrw(r6w!rC8(P|v|LGyCoZ#N_xw-OkxgFC1yQ4_e}-uHsI=fVC`*%iQOdl%mfZX;8H=*XhuRzmb!9!LwaBYWoa5^-$H&8jq2`b~Lye+dIgQ!^j;RYlU!YBUit9|_F+^c`7e--W z7iM8~7paFj>OAEsj8WS3Jb?)~IEf5$lrKVMz?E06t#@h7nEK1Mn_F@Rlo1ap8BS%>=pG6S5XCN;q1F@94czvGilkDPR} z>LI-y=AGkbLNS}w?9EfVK;2pOV(3aP?Pq9P!K!9(aahw~ e#6|iF6m`eOzf5LWc!jT?g;!HFyhek8*Z%{PO<>^w diff --git a/build/classes/java/main/semaphore/Semaphore.class b/build/classes/java/main/semaphore/Semaphore.class index 46ce2ecb0fd05ade46b044b47cf90acbfbaf1f36..ac7fd47119a94b494d163a7f5076377e46f69ee2 100644 GIT binary patch literal 1378 zcmZuw%W@M(6g@4;8cU2VBQV4^0U1nU2_lg|o+2b5a8Q*9Ny%l3$|mhm$7(F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b/src/main/java/join/Main.java index fedf709..aefad1c 100644 --- a/src/main/java/join/Main.java +++ b/src/main/java/join/Main.java @@ -9,19 +9,22 @@ public class Main { public static void main(String arg[]) throws Exception { Random r = new Random(); ArrayList threads = new ArrayList(); + //create some threads for (int i=0; i<10; i++) { MyThread mt = new MyThread(r); threads.add(mt); } System.out.println("All threads have been created."); + //start all the threads for (Thread t: threads) { t.start(); } System.out.println("All threads have been started."); System.out.println("Start waiting for all thread to finish..."); - //wait all the thread to finish + + //wait all the threads to finish for (Thread t : threads) { t.join(); } diff --git a/src/main/java/semaphore/Main.java b/src/main/java/semaphore/Main.java index 1315fcb..3e82d2b 100644 --- a/src/main/java/semaphore/Main.java +++ b/src/main/java/semaphore/Main.java @@ -8,13 +8,14 @@ public class Main { Random r = new Random(); ArrayList threads = new ArrayList(); Semaphore s = new Semaphore(4); - //create some threads + + //Create some threads for (int i=0; i<10; i++) { MyThread mt = new MyThread(r, i, s); threads.add(mt); } - //start all the threads + //Start all the threads for (Thread t: threads) { t.start(); } diff --git a/src/main/java/semaphore/MyThread.java b/src/main/java/semaphore/MyThread.java index b15b661..0209e0a 100644 --- a/src/main/java/semaphore/MyThread.java +++ b/src/main/java/semaphore/MyThread.java @@ -10,23 +10,27 @@ public class MyThread extends Thread { MyThread(Random r, int i, Semaphore s) { rnd = r; id = i; - sem=s; + sem = s; } public void run() { - wasteSomeTime(); //Simulate the thread is doing something else + //Simulate the thread is doing something else + wasteSomeTime(); System.out.println("Thread " + id + " wants to enter in the critical region"); sem.enter(); System.out.println("Thread " + id + " entered in the critical region!"); - wasteSomeTime(); //it takes some times to compleate the work in the critical region + + //It takes some times to complete the work in the critical region + wasteSomeTime(); System.out.println("Thread " + id + " is going to get out from the critical region"); sem.exit(); - }//end run + } + //End run private void wasteSomeTime() { int seconds = rnd.nextInt(10) + 1; try {Thread.sleep(seconds*1000);} catch(Exception ex) {ex.printStackTrace();} } -} //end class +} diff --git a/src/main/java/semaphore/Semaphore.java b/src/main/java/semaphore/Semaphore.java index f075e31..a932afc 100644 --- a/src/main/java/semaphore/Semaphore.java +++ b/src/main/java/semaphore/Semaphore.java @@ -1,9 +1,13 @@ -package semaphore;//Classe che implementa tramite wait e notify un Semaforo. -//Se non vi ricordate cosa sia un semaforo, google is your best friend. +package semaphore; +/* +This class implements a samafor through the use of wait and notify + */ public class Semaphore { - private int maxNumber; //numero massimo di thread - private int threadsIn; //conteggio dei thread nell'area critica + //Maximum number of threads + private int maxNumber; + //Number of threads in the critical region + private int threadsIn; Semaphore(int max) { maxNumber = max; @@ -12,7 +16,8 @@ public class Semaphore { public synchronized void enter() { System.out.println("" + threadsIn + " in the critical region..."); - //quando abbiamo raggiunto il numero massimo di thread, chi vuole entrare aspetta + + // When the maximum number of threads is reached, new threads have to wait while (threadsIn >= maxNumber) { try {this.wait();} catch(InterruptedException ie) {ie.printStackTrace();} @@ -23,7 +28,7 @@ public class Semaphore { public synchronized void exit() { threadsIn--; - //quando un thread esce dall'area critica, sveglia qualcuno in attesa di entrare (se presente) + // When a thread exits the critical region, it wakes another threads (if there is one) that's waiting to enter the critical region this.notify(); } } -- 2.18.1