From 5b1d0fb4add8c8e033c00f6a5220f5bdee5bdd3e Mon Sep 17 00:00:00 2001 From: esoe Date: Tue, 24 Jan 2023 09:33:33 +0300 Subject: [PATCH] qq --- java/samples/multithread/GazStation/build.xml | 73 + .../build/classes/.netbeans_automatic_build | 0 .../build/classes/.netbeans_update_resources | 0 .../build/classes/gazstation/Car.class | Bin 0 -> 1822 bytes .../classes/gazstation/FilingColumn.class | Bin 0 -> 1290 bytes .../classes/gazstation/GazProducer.class | Bin 0 -> 1578 bytes .../build/classes/gazstation/GazStation.class | Bin 0 -> 976 bytes .../build/classes/gazstation/MainClass.class | Bin 0 -> 900 bytes .../multithread/GazStation/manifest.mf | 3 + .../GazStation/nbproject/build-impl.xml | 1420 +++++++++++++++++ .../GazStation/nbproject/genfiles.properties | 8 + .../nbproject/private/private.properties | 2 + .../GazStation/nbproject/private/private.xml | 11 + .../GazStation/nbproject/project.properties | 74 + .../GazStation/nbproject/project.xml | 15 + .../GazStation/src/gazstation/Car.java | 50 + .../src/gazstation/FilingColumn.java | 43 + .../src/gazstation/GazProducer.java | 37 + .../GazStation/src/gazstation/GazStation.java | 29 + .../GazStation/src/gazstation/MainClass.java | 25 + .../samples/multithread/GazStation2/build.xml | 73 + .../build/classes/.netbeans_automatic_build | 0 .../build/classes/.netbeans_update_resources | 0 .../build/classes/gazstation2/Car.class | Bin 0 -> 1622 bytes .../classes/gazstation2/FilingColumn.class | Bin 0 -> 1649 bytes .../classes/gazstation2/GazProducer.class | Bin 0 -> 1276 bytes .../classes/gazstation2/GazStation.class | Bin 0 -> 999 bytes .../build/classes/gazstation2/MainClass.class | Bin 0 -> 905 bytes .../multithread/GazStation2/manifest.mf | 3 + .../GazStation2/nbproject/build-impl.xml | 1420 +++++++++++++++++ .../GazStation2/nbproject/genfiles.properties | 8 + .../nbproject/private/private.properties | 2 + .../GazStation2/nbproject/project.properties | 74 + .../GazStation2/nbproject/project.xml | 15 + .../GazStation2/src/gazstation2/Car.java | 43 + .../src/gazstation2/FilingColumn.java | 49 + .../src/gazstation2/GazProducer.java | 34 + .../src/gazstation2/GazStation.java | 28 + .../src/gazstation2/MainClass.java | 25 + .../MultithreadingExample/build.xml | 73 + .../build/classes/.netbeans_automatic_build | 0 .../build/classes/.netbeans_update_resources | 0 .../classes/multithreadingexample/Bank.class | Bin 0 -> 495 bytes .../multithreadingexample/BankAccount.class | Bin 0 -> 985 bytes .../multithreadingexample/BankOperation.class | Bin 0 -> 1589 bytes .../multithreadingexample/MainClass.class | Bin 0 -> 1266 bytes .../multithreadingexample/MyThread.class | Bin 0 -> 637 bytes .../MultithreadingExample/manifest.mf | 3 + .../nbproject/build-impl.xml | 1420 +++++++++++++++++ .../nbproject/genfiles.properties | 8 + .../nbproject/private/private.properties | 2 + .../nbproject/private/private.xml | 9 + .../nbproject/project.properties | 74 + .../nbproject/project.xml | 15 + .../src/multithreadingexample/Bank.java | 19 + .../multithreadingexample/BankAccount.java | 44 + .../multithreadingexample/BankOperation.java | 32 + .../src/multithreadingexample/MainClass.java | 38 + .../src/multithreadingexample/MyThread.java | 24 + .../MultithreadingExample_2/build.xml | 73 + .../build/classes/.netbeans_automatic_build | 0 .../build/classes/.netbeans_update_resources | 0 .../multithreadingexample_2/Bank.class | Bin 0 -> 501 bytes .../multithreadingexample_2/BankAccount.class | Bin 0 -> 789 bytes .../BankOperation.class | Bin 0 -> 1599 bytes .../MultithreadingExample_2.class | Bin 0 -> 1501 bytes .../multithreadingexample_2/MyThread1.class | Bin 0 -> 1172 bytes .../multithreadingexample_2/MyThread2.class | Bin 0 -> 598 bytes .../MultithreadingExample_2/manifest.mf | 3 + .../nbproject/build-impl.xml | 1420 +++++++++++++++++ .../nbproject/genfiles.properties | 8 + .../nbproject/private/private.properties | 2 + .../nbproject/project.properties | 74 + .../nbproject/project.xml | 15 + .../src/multithreadingexample_2/Bank.java | 17 + .../multithreadingexample_2/BankAccount.java | 42 + .../BankOperation.java | 30 + .../MultithreadingExample_2.java | 49 + .../multithreadingexample_2/MyThread1.java | 27 + .../multithreadingexample_2/MyThread2.java | 19 + 80 files changed, 7104 insertions(+) create mode 100644 java/samples/multithread/GazStation/build.xml create mode 100644 java/samples/multithread/GazStation/build/classes/.netbeans_automatic_build create mode 100644 java/samples/multithread/GazStation/build/classes/.netbeans_update_resources create mode 100644 java/samples/multithread/GazStation/build/classes/gazstation/Car.class create mode 100644 java/samples/multithread/GazStation/build/classes/gazstation/FilingColumn.class create mode 100644 java/samples/multithread/GazStation/build/classes/gazstation/GazProducer.class create mode 100644 java/samples/multithread/GazStation/build/classes/gazstation/GazStation.class create mode 100644 java/samples/multithread/GazStation/build/classes/gazstation/MainClass.class create mode 100644 java/samples/multithread/GazStation/manifest.mf create mode 100644 java/samples/multithread/GazStation/nbproject/build-impl.xml create mode 100644 java/samples/multithread/GazStation/nbproject/genfiles.properties create mode 100644 java/samples/multithread/GazStation/nbproject/private/private.properties create mode 100644 java/samples/multithread/GazStation/nbproject/private/private.xml create mode 100644 java/samples/multithread/GazStation/nbproject/project.properties create mode 100644 java/samples/multithread/GazStation/nbproject/project.xml create mode 100644 java/samples/multithread/GazStation/src/gazstation/Car.java create mode 100644 java/samples/multithread/GazStation/src/gazstation/FilingColumn.java create mode 100644 java/samples/multithread/GazStation/src/gazstation/GazProducer.java create mode 100644 java/samples/multithread/GazStation/src/gazstation/GazStation.java create mode 100644 java/samples/multithread/GazStation/src/gazstation/MainClass.java create mode 100644 java/samples/multithread/GazStation2/build.xml create mode 100644 java/samples/multithread/GazStation2/build/classes/.netbeans_automatic_build create mode 100644 java/samples/multithread/GazStation2/build/classes/.netbeans_update_resources create mode 100644 java/samples/multithread/GazStation2/build/classes/gazstation2/Car.class create mode 100644 java/samples/multithread/GazStation2/build/classes/gazstation2/FilingColumn.class create mode 100644 java/samples/multithread/GazStation2/build/classes/gazstation2/GazProducer.class create mode 100644 java/samples/multithread/GazStation2/build/classes/gazstation2/GazStation.class create mode 100644 java/samples/multithread/GazStation2/build/classes/gazstation2/MainClass.class create mode 100644 java/samples/multithread/GazStation2/manifest.mf create mode 100644 java/samples/multithread/GazStation2/nbproject/build-impl.xml create mode 100644 java/samples/multithread/GazStation2/nbproject/genfiles.properties create mode 100644 java/samples/multithread/GazStation2/nbproject/private/private.properties create mode 100644 java/samples/multithread/GazStation2/nbproject/project.properties create mode 100644 java/samples/multithread/GazStation2/nbproject/project.xml create mode 100644 java/samples/multithread/GazStation2/src/gazstation2/Car.java create mode 100644 java/samples/multithread/GazStation2/src/gazstation2/FilingColumn.java create mode 100644 java/samples/multithread/GazStation2/src/gazstation2/GazProducer.java create mode 100644 java/samples/multithread/GazStation2/src/gazstation2/GazStation.java create mode 100644 java/samples/multithread/GazStation2/src/gazstation2/MainClass.java create mode 100644 java/samples/multithread/MultithreadingExample/build.xml create mode 100644 java/samples/multithread/MultithreadingExample/build/classes/.netbeans_automatic_build create mode 100644 java/samples/multithread/MultithreadingExample/build/classes/.netbeans_update_resources create mode 100644 java/samples/multithread/MultithreadingExample/build/classes/multithreadingexample/Bank.class create mode 100644 java/samples/multithread/MultithreadingExample/build/classes/multithreadingexample/BankAccount.class create mode 100644 java/samples/multithread/MultithreadingExample/build/classes/multithreadingexample/BankOperation.class create mode 100644 java/samples/multithread/MultithreadingExample/build/classes/multithreadingexample/MainClass.class create mode 100644 java/samples/multithread/MultithreadingExample/build/classes/multithreadingexample/MyThread.class create mode 100644 java/samples/multithread/MultithreadingExample/manifest.mf create mode 100644 java/samples/multithread/MultithreadingExample/nbproject/build-impl.xml create mode 100644 java/samples/multithread/MultithreadingExample/nbproject/genfiles.properties create mode 100644 java/samples/multithread/MultithreadingExample/nbproject/private/private.properties create mode 100644 java/samples/multithread/MultithreadingExample/nbproject/private/private.xml create mode 100644 java/samples/multithread/MultithreadingExample/nbproject/project.properties create mode 100644 java/samples/multithread/MultithreadingExample/nbproject/project.xml create mode 100644 java/samples/multithread/MultithreadingExample/src/multithreadingexample/Bank.java create mode 100644 java/samples/multithread/MultithreadingExample/src/multithreadingexample/BankAccount.java create mode 100644 java/samples/multithread/MultithreadingExample/src/multithreadingexample/BankOperation.java create mode 100644 java/samples/multithread/MultithreadingExample/src/multithreadingexample/MainClass.java create mode 100644 java/samples/multithread/MultithreadingExample/src/multithreadingexample/MyThread.java create mode 100644 java/samples/multithread/MultithreadingExample_2/build.xml create mode 100644 java/samples/multithread/MultithreadingExample_2/build/classes/.netbeans_automatic_build create mode 100644 java/samples/multithread/MultithreadingExample_2/build/classes/.netbeans_update_resources create mode 100644 java/samples/multithread/MultithreadingExample_2/build/classes/multithreadingexample_2/Bank.class create mode 100644 java/samples/multithread/MultithreadingExample_2/build/classes/multithreadingexample_2/BankAccount.class create mode 100644 java/samples/multithread/MultithreadingExample_2/build/classes/multithreadingexample_2/BankOperation.class create mode 100644 java/samples/multithread/MultithreadingExample_2/build/classes/multithreadingexample_2/MultithreadingExample_2.class create mode 100644 java/samples/multithread/MultithreadingExample_2/build/classes/multithreadingexample_2/MyThread1.class create mode 100644 java/samples/multithread/MultithreadingExample_2/build/classes/multithreadingexample_2/MyThread2.class create mode 100644 java/samples/multithread/MultithreadingExample_2/manifest.mf create mode 100644 java/samples/multithread/MultithreadingExample_2/nbproject/build-impl.xml create mode 100644 java/samples/multithread/MultithreadingExample_2/nbproject/genfiles.properties create mode 100644 java/samples/multithread/MultithreadingExample_2/nbproject/private/private.properties create mode 100644 java/samples/multithread/MultithreadingExample_2/nbproject/project.properties create mode 100644 java/samples/multithread/MultithreadingExample_2/nbproject/project.xml create mode 100644 java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/Bank.java create mode 100644 java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/BankAccount.java create mode 100644 java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/BankOperation.java create mode 100644 java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/MultithreadingExample_2.java create mode 100644 java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/MyThread1.java create mode 100644 java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/MyThread2.java diff --git a/java/samples/multithread/GazStation/build.xml b/java/samples/multithread/GazStation/build.xml new file mode 100644 index 0000000..aaf6774 --- /dev/null +++ b/java/samples/multithread/GazStation/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project GazStation. + + + diff --git a/java/samples/multithread/GazStation/build/classes/.netbeans_automatic_build b/java/samples/multithread/GazStation/build/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/java/samples/multithread/GazStation/build/classes/.netbeans_update_resources b/java/samples/multithread/GazStation/build/classes/.netbeans_update_resources new file mode 100644 index 0000000..e69de29 diff --git a/java/samples/multithread/GazStation/build/classes/gazstation/Car.class b/java/samples/multithread/GazStation/build/classes/gazstation/Car.class new file mode 100644 index 0000000000000000000000000000000000000000..bf05ff8f2410fac80d3cd0fd841d3d78ab9685f8 GIT binary patch literal 1822 zcmaJ>T~`}b6x|a7lT3#XLjvWa7;K>-m858?3Y6MnsnnFxf++aaA-N4>lS$SvVPT&v zYq?y@pWuV9eYCJhV2RRqpC{Q389M*uFt)G&a{ z&0OvEn6;3GNT&@hXe z5~XJIv4%O^3Uc^FLkhP8n6HOY-2mkelNb~a%NXH6K^Mq;s0veP0Z zHbw55WfeS60)-n`-q{qkZDs_)TBc0Pbfy(VVhslMG$i>ZThLosRiJs$v!3B&QT;c%UPT zbp?|Q_J>=J${38c&6tF${>aUv|De_aRv2NARLa%ugo57D*FFk53B6C#XEGDgIv{@q zZO04$LcCg=Ev?(a$S7#u$O%zov&3%6TB(-Ua;UuAm>XfAdU|`E`Q3&i@~mf}#Pf(( zY_pJDV8c3;SQvTP4o0ykEFzD-svS;rNWCa@>}SCLISx1luZ(QO*hxbIbk+)foDefA zN_siAPNYGOo5myF0k5S3SwZ@S!=CIR@+++fuciyRQr;S)Rih1?nfG<3c1El22KUAz z`ZLU|cQKjiDw}nHUl4wez$U{WS3cQ1oE6!j^^+kCbN@Wwc4_J3ycDlM3Bz{){}cFA zhiF;ZhuRUVATSkQ*+Z}|Q$}zX+96KyM33*GwSu-#JBPjsIzn%7!ObAo6@)72eDeHP z#`Hr&E1DT4#wfk~CIY9q+k-Z~_3<}^e%!?wjPRt3T>5aCS9g%UWQ7ZOoAW6D0b-<7 zLLtGo7M>?LE4-*<9Az#hab+$;@qL8j9kDVZ@e5_N#_QRTUZf+OVM;>>%1H*g1;zf)D}gG~`N($nTE)x_Ds~ABp*iur2YW1evJ=bnT&=x}3h!|1&P0 zl&yzqc`}93>uEkOEARx%Tg0T6g`s!CW)g!NP-a1;ETx!#8-R;@qwafcqo=tx^hUyI69f3!o(6+%EE2E(ieFbm=b74fG%1DLbgDQd+ zLN^YJFdW7RMny=6a0EwX919~1HHhP4JRw3Rh?8PG6~<|t5nyL!WMzy=kQdD2ZQXt> zL7HM_F3pw;Mw!_?3GHL1ZMx$U{A%isgusMTFeG&3Oxu{LlopKgZGFLFC6aUUx^+h{ zn<8%(1MWj}NkVU~s6ShBb=P$4^rUH-c5%Y7DkVEhwxZ!qRt$^K>Qst^fd^i;bKceS zkEiv;CX}of3R`_t5}tP|<-9>SvUjzjjy}?#=n8t#C!tf!(-qgW(zkTG;FJ`c!?=PN z;tG1OTgG_>7jRL*B}~Y;tl$bJCG>d9EZr`q=iM^(UaFXu=gC0rZEdaosU2VJLe780V|;GZW%fbMMs(ZNL_&!R=K?F4a)A=`1y2g?^N3rT)WQGRbe z{&+{c8LtUPKWHra7!%BHdO48LHXv!6@ZH^jzf1aFMPMCm8bkY_Aw^V!Ag{Df@OdVL)hnW#~b)fZZfeRC;NV`48S)KqLu?V*wnM!)RSpY z-Y4aIgf PzXfHQf+Y5f^BDRGRc;?{ literal 0 HcmV?d00001 diff --git a/java/samples/multithread/GazStation/build/classes/gazstation/GazProducer.class b/java/samples/multithread/GazStation/build/classes/gazstation/GazProducer.class new file mode 100644 index 0000000000000000000000000000000000000000..e71e0af480237fa55a3d8f079ad4f6d0056132b2 GIT binary patch literal 1578 zcmaJ>-%}e^6#g~@Hmpm5@FN7$Hn!9TsKjdh1#Pv(QmLWPf++r8ve&S6vzyuMV(nAa z(b4g#|3F{+YMBxknYJ_b&8N-3Ib2iwV4>QT=i!cljImLGHhz;#G|%uW5K4Gu<3!Rh-q(gS;HhX*iEJRJ^I7 zANd3>NO@5Xa|yg9HjR+I37~T*Y-AD_GU>F2)F=aU}39JAd79Ot-9K4ezOVU&lH=P>^c5T=6{? z?P6frrtlP;c^cU+F+Hx|=C~d1h5On1_u*ds>-sl@dpmqs|8^#;<3oHThmV<;Y`8zI z;}d+UV7RS0+S2kjzD8zOH$7pP2UJTNH$>4_FwjCtEBDK&DQ%_DkzEA4}qxCaNnvtdFV>r=}9StO- z=%Ow~s}W*J^BX0DF`OimEO&IqXS^n=6P%ACeodvnKhcYriV+phK~Zt?ce2TGzl$d( zC?RiQGZ#M+hr~U*hi4u@FYKddeHVxNay9h!nVaXPGBxy((?0sCPbLRy7^G?_Im}57 xDKc#(Zy53oKMIuqQv{YFof#%6OKmm^(}b(?!I!0BLlMdpPBDFK6xziw{TGfvh3^0W literal 0 HcmV?d00001 diff --git a/java/samples/multithread/GazStation/build/classes/gazstation/GazStation.class b/java/samples/multithread/GazStation/build/classes/gazstation/GazStation.class new file mode 100644 index 0000000000000000000000000000000000000000..34e9cdb5897ac1286212ea740e1f0e0961ef183c GIT binary patch literal 976 zcmZ`&OHUI~7(KVIX@}_(3RJ09@zDZOQG5mCLK55*C8;4{=d?`f;BeRKQk&yPNUO*~hTz_NlnDgs!JA%eT|aZka0 zl`D6ODxxUGu!7Yn)>J&exbqD}i9Kv@a0ab`A}JWW}_Nx9w)laNp}Si%6#8)OBlLcTHK3 zz>xRRYzaggh9@0K%N0xiJt|I4{nM^~JW?lVXfe#5>m0W0hAXgCoD@%WBf~|8T?@>x z=do&WQZ(Vm?$oN&cIyV6WK-kD*N^nix`tWIaW*t-T`@onNu)HSkrBvFaK(hG#NPN=7SNy4@(h zs~s72Zwjh@X?aGIU(0E8BU>4eO{cu)nl`_IYv@h3J$nVr>u@YdmQ7u8C>)$Z6)(+} z9B`O(a6J@w0~5Ta0dQzY@lBOu;2I>xp%Krrdd*sJO|5hxR(c2=bP+s9=!{qZ^L!@A z0JR~+>6FF-D{ZL3;=nP69IlQ0UQi`}a~*_#BHlxUhRSz@S)URgddhzcIn0&Cb-pn} ziUv!_k8C~=lE=>X5ItD!BDULsnwhzPwswK|I9!IYz~f^Kkfv3Z9x`BIs2&BR4{q=< RL0%j;xhuzVi@X4C{{=5c;Sc}- literal 0 HcmV?d00001 diff --git a/java/samples/multithread/GazStation/build/classes/gazstation/MainClass.class b/java/samples/multithread/GazStation/build/classes/gazstation/MainClass.class new file mode 100644 index 0000000000000000000000000000000000000000..c16d10bcba59eb4a2d379a963a5ff21b52008fdd GIT binary patch literal 900 zcmaJY|rWd}Jn@wht zl~!Fg*JS9c_$+BeZ~TtHc%>oVcOn`2t)N_$ez4M%oz4>3b{G(MH!9omoh&zH&?wiU z&<`3*YMSu*u5xx=h60I;G%GSx1Tt)JKx#lgL3R-w+vx8bu0^u`wkq2_p%x|u>{@F# ztb0#=wav)6$~h&>!7xUcy|4!73uOOQ{dm`JZh1sZ;@`R-9L!=)nX-esm{&Xt4(=(k z^aZl>XzDq>*7pH6OFi zq<@vLzd)<#k8%ln4>QHwA++^F=<5eClCgc5xqVpsh#z36*44zv-(QQ>($TVh-^dt~ zdq|fu#=?Wx1S{>XLHN58qC*L}(i@PZO;K|iMf!P+<0Y~^aRnHNBhO5hn>|4cmoY(0 nQS7}+Z{itpn55)ujIuC(A#UNi_zCv}miiJu*e-B`u!gBWbPC2a literal 0 HcmV?d00001 diff --git a/java/samples/multithread/GazStation/manifest.mf b/java/samples/multithread/GazStation/manifest.mf new file mode 100644 index 0000000..1574df4 --- /dev/null +++ b/java/samples/multithread/GazStation/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/java/samples/multithread/GazStation/nbproject/build-impl.xml b/java/samples/multithread/GazStation/nbproject/build-impl.xml new file mode 100644 index 0000000..ef8ab78 --- /dev/null +++ b/java/samples/multithread/GazStation/nbproject/build-impl.xml @@ -0,0 +1,1420 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/samples/multithread/GazStation/nbproject/genfiles.properties b/java/samples/multithread/GazStation/nbproject/genfiles.properties new file mode 100644 index 0000000..0334824 --- /dev/null +++ b/java/samples/multithread/GazStation/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=9cd5ec1b +build.xml.script.CRC32=76050ae8 +build.xml.stylesheet.CRC32=8064a381@1.80.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=9cd5ec1b +nbproject/build-impl.xml.script.CRC32=84c4fcda +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/java/samples/multithread/GazStation/nbproject/private/private.properties b/java/samples/multithread/GazStation/nbproject/private/private.properties new file mode 100644 index 0000000..11ff3b8 --- /dev/null +++ b/java/samples/multithread/GazStation/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=C:\\Users\\denis.LAPTOP-4LI8UQ4O\\AppData\\Roaming\\NetBeans\\8.2\\build.properties diff --git a/java/samples/multithread/GazStation/nbproject/private/private.xml b/java/samples/multithread/GazStation/nbproject/private/private.xml new file mode 100644 index 0000000..b3b8b31 --- /dev/null +++ b/java/samples/multithread/GazStation/nbproject/private/private.xml @@ -0,0 +1,11 @@ + + + + + + file:/C:/Users/denis.LAPTOP-4LI8UQ4O/OneDrive/Документы/NetBeansProjects/GazStation/src/gazstation/Car.java + file:/C:/Users/denis.LAPTOP-4LI8UQ4O/OneDrive/Документы/NetBeansProjects/GazStation/src/gazstation/GazProducer.java + file:/C:/Users/denis.LAPTOP-4LI8UQ4O/OneDrive/Документы/NetBeansProjects/GazStation/src/gazstation/FilingColumn.java + + + diff --git a/java/samples/multithread/GazStation/nbproject/project.properties b/java/samples/multithread/GazStation/nbproject/project.properties new file mode 100644 index 0000000..fc4f33f --- /dev/null +++ b/java/samples/multithread/GazStation/nbproject/project.properties @@ -0,0 +1,74 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# \u0424\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 build.classes.dir, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/GazStation.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=gazstation.MainClass +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/java/samples/multithread/GazStation/nbproject/project.xml b/java/samples/multithread/GazStation/nbproject/project.xml new file mode 100644 index 0000000..0236956 --- /dev/null +++ b/java/samples/multithread/GazStation/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + GazStation + + + + + + + + + diff --git a/java/samples/multithread/GazStation/src/gazstation/Car.java b/java/samples/multithread/GazStation/src/gazstation/Car.java new file mode 100644 index 0000000..66a4c9d --- /dev/null +++ b/java/samples/multithread/GazStation/src/gazstation/Car.java @@ -0,0 +1,50 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package gazstation; + +import java.util.Random; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author denis + */ +class Car extends Thread{ + public int tank; + private int max = 40; + public String name; + + @Override + public void run() { + while(true){ + fuel(); + try {Thread.sleep(1000);} catch (InterruptedException ex) {} + int fuel = new Random().nextInt(40); + tank -= fuel; + System.out.println(name + ": израсходовал " + fuel + " л. Объем топлива: " + tank); + } + } + + public Car(String name) { + this.name = name; + this.tank = new Random().nextInt(max-20); + } + + public void fuel(){ + int fuel = max - tank; + boolean res = GazStation.getState().column1.getFuel(fuel); + if(!res) { + System.out.println(name + ": не достаточно топлива. Ожидает."); + + try {Thread.sleep(2000);} catch (InterruptedException ex) {} + fuel(); + }else { + tank += fuel; + System.out.println("--------------------------" + name + ": заправил " + fuel + " л. Объем топлива: " + tank); + } + } +} diff --git a/java/samples/multithread/GazStation/src/gazstation/FilingColumn.java b/java/samples/multithread/GazStation/src/gazstation/FilingColumn.java new file mode 100644 index 0000000..b4e5259 --- /dev/null +++ b/java/samples/multithread/GazStation/src/gazstation/FilingColumn.java @@ -0,0 +1,43 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package gazstation; + +import java.util.Random; + +/** + * + * @author denis + */ +class FilingColumn { + + private int bigTank; + private boolean isOrder; + + public FilingColumn (){ + bigTank = new Random().nextInt(500); + isOrder = true; + } + + + public synchronized boolean getFuel(int fuel) { + if(isOrder){ + if(bigTank + + + + + + + + + + Builds, tests, and runs the project GazStation2. + + + diff --git a/java/samples/multithread/GazStation2/build/classes/.netbeans_automatic_build b/java/samples/multithread/GazStation2/build/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/java/samples/multithread/GazStation2/build/classes/.netbeans_update_resources b/java/samples/multithread/GazStation2/build/classes/.netbeans_update_resources new file mode 100644 index 0000000..e69de29 diff --git a/java/samples/multithread/GazStation2/build/classes/gazstation2/Car.class b/java/samples/multithread/GazStation2/build/classes/gazstation2/Car.class new file mode 100644 index 0000000000000000000000000000000000000000..692a7e3e730dd995c3972bc8a82290a6d21a3e3b GIT binary patch literal 1622 zcmaJ>T~kv>7=AVhoaAtj7{iB#Vi3g;3#r!97SXCyEEd!PrG{I=Y8If-QWKD`4ND# zSTvEsnI^9J3qLl|jaLnvHSn5=W(@1$^%x;<#PB9Y44gC3f?>Tgs#oWuxS;2^qPVE% zOC~O3OtVxmZ=1M+@fe4zCf>nB-H#C%xMtv8fru}iy8>cDAY7Dd+;C)32_z;zm#Z>Y zkj`>$#`kPz`5X~m+2NQOm?Lh?%@fx)X*=qAxwxpjS-DuKo^+RFVNQCs{$JmWd{$Nk zy0Nv#JNAme!O3NLZ^f6s?K)?2W6~pk>x?g#?oP>4{ZyapEe|=$UsTdr8Jcm+-jbSB ztEzCxaopNbG9??N-dI(hXXh2knn!KN_AdyuXBq(YSabwtjd0x7s-sjeq(ioF5`7jX zF(uIRGzSxoPv&yTSNSVzORA)03&g8{vTql1)6&ViMGHgv^mW{@@Dh3q+_dl>rUg2m zQq?3}F588?@+_p$Yhebn0;!R7uoG|`+D!Y;8C#2?_uyD*iCE5`vU27usf6v zeh4=9?gv}JFX_E+2>CVG5LhUTJxC+y)iMsmZ`;GYmzTkd{tz3xMkYgYbm$g z+)eh5&ybZY>Y~U}NjYR5d{I%Jt5ZEmJlIW#|6`8&ZY`~Bhs^Up5*(@);8{V8sHEi; zSjvvZd|Z|H*ow6pN0$}#OP@`0gw!vF(Sfn#7Rp8EG-1zx*k8OoV^t$zU5x~dHZsuD zc=evJWgB7oc1#Q`uvJpL*nB1+ba!zT(iP^+&OmS7atwXkKhA%@6B*`wJ3N|-Cx663 zwgQnvXa|vXM5cDpJiiSio~a;uK0CjOSa*I4v4=2s(L#%r-9&2z2NG=@x+{n$4syZG z7}pgfDme755bOItZP34k1lrL=e<$ei7@{0IId;)<7#%o5RVfTo|2+3^QFT8NY2y1Z z%sbaZ%^|jEhAW{pV*pvsr}!N}I(3!DJfSDE~NRX@MOz!nznz6W2?3 zLO&CAw_h>{o#uYcuhWws-9g7DISB<+|0XLz&pb`v mCuzyhN4CLtf8Do!({-9eH6<+wKY=Ocm=fI$uaF>w(|-e)D0evk literal 0 HcmV?d00001 diff --git a/java/samples/multithread/GazStation2/build/classes/gazstation2/FilingColumn.class b/java/samples/multithread/GazStation2/build/classes/gazstation2/FilingColumn.class new file mode 100644 index 0000000000000000000000000000000000000000..fb00ab8410135839694955f0de28e5687c87f691 GIT binary patch literal 1649 zcmZ`(OLN;)6#lO5Shi7{*l8Y3T&nUYjzjDc-f=0Al(YsnNt+Nzc?^mzj9OXBI5Goe z0dzXU4F7-)3pQ+6q?y?1U`Y3@%kAHqW0Pq4n zPGAgq1?Lh7Auq*qag1VCis$1rcu~Pi3B-_(<7K=ewO3=9lkY+T=kZzs7x20iZ%BhT zW0;R&K^|X>;VlJ=3N8sKn`U)Qw{HrFqCnK#UfwcnF0ONN-n32kftA+dfk-k?qOwS|)pm1xkVORnqnFm}K^m?He~S1;eZqHlGP zD0-z5gp6d0l1O6JY1GRG!4Q117gO$r{<*FqjZ*?cQqMPB)5>4d?TS-VaT!Gw<2b2e z0+R~fR`Cu>0%N|VrQ6l~s#_<)`G#p#jJkp=DweRUVg*+P3UiwGyVumbJ@26NZRfVP z!~a3&J8m9mQuXe8ZSS79>+R$;??`ba?2ytbe1Zs&Wi>HT&D$eboH{-_Qf*2rhR zym`YYyKJCseBl;tYO>nwXi&$XI$v(PMvX0W8ay8<`E@g${0fWavUG-C<5Udx=40C# z$<}NBoEK&bW7kwrr(ej!wN$)j8KkJjxpdk69H-v0%!09R{~Gssc!f@-!l9_b`Jx;PzeG>{msc9 z=Yg*C89a@%UFScEEli&~bdLUjuVjq$Psr^;X(L9U@##GzT6ip_QnYZah2!@ym~CMw z8z%6daXGsoeJZ3fO)Z)Jq>1GJ?x__04r2^cPq%O)H4yV2WJ{(GG|rH1{`s1!Fzi>Luv6UR9}-)P|TU%nwfi)_IRV}+3W7eMNdCIA2c literal 0 HcmV?d00001 diff --git a/java/samples/multithread/GazStation2/build/classes/gazstation2/GazProducer.class b/java/samples/multithread/GazStation2/build/classes/gazstation2/GazProducer.class new file mode 100644 index 0000000000000000000000000000000000000000..c8ef3c93da355316059c712fc46e2a0c3069c02a GIT binary patch literal 1276 zcmaJ>TT|0e5dKmsDIqA7OXVh2R7#cB3tj=0q9|IC5r!Gx4CGj%X~KkrQQmaMC!hQS z{sv^Eb?nFw@G1Nu$M3W_6j2{?_UxYBZ@=BMCqI6E+W|0&Sq&W+YC=0wO&CTxhI1Ou zV??7Rqav$8#gJSsXt;<=DlThi#!w8SQeKhE)fleH!|PJHq2i{BF$Imwt{oH|1wHwK zv9abGzU4ZXveTArIfbd}ne-aB9Lv9@pg;9*x8X$v(J9vy3XbJ1N6ZGrCE+a?OExX> zyt{1Ji-u=Oea{&6SFAM!-3Ku58yj<;YX-~0W99}gAi0K=1Rr$0LdFsPk}#aL%)A?T z%OWq)^P`uI!rfnUPrGk---Vm}cEWGT3Hm(5BOQ4>rceE~))o1iV6{&RE1odS1E%>mYrZJ5^={xR z=&Uu>aXWcAitK88wTOde1?sAFvUzcxsk+;!l{qG_Qgy^@f5stlG&M8KQjXWt zte-ym8m2j2y*25};6`J0RXC(O@;CHD3HSO+wtbBM&#_hze$FZ^7|yHe$dOjecWbOU zSE<9XV@UD=cJPTRh{##tu7Udmj&tp%HcfkkQcIViq|a?5@|ju$JzS5{7idEiamc6L zORcNsjXv~KV_X%L1B(+F;F-j{O{q|}Y@s0@E#XMIgvLK%6Nr(7&HxFk*8=unle9F_ za*`5qTDh0N??_0J%~ha2D literal 0 HcmV?d00001 diff --git a/java/samples/multithread/GazStation2/build/classes/gazstation2/GazStation.class b/java/samples/multithread/GazStation2/build/classes/gazstation2/GazStation.class new file mode 100644 index 0000000000000000000000000000000000000000..8578130ac1f4c78a2cc8906d6ca09aa17a89f32d GIT binary patch literal 999 zcmZ`%+iuf96r9b?iRUg^iJ(Fj4AZOgIz=K{%EeNP~@;~tm-g{I}0Z+hLf>Aln2Haq2}Yv}f#?pd;q znkoN-btI7On7(8rY@t^FzgB?^Hr01M_n>E(p1@KqhK?DK$H|PG3QW-F)!2M&YK)PF zvfBnz2ra2Cx91rqS*4{b+iQpVCtbr7t}z-CM>)j<)KEZCLkVSp*>TXAoa9(ku&!YP zkLV`&`twWB56*&<;Ia~&2Is*g%OM-Xps!$4!(%+r@Kg%V{KXkvi9k`Fu3_s=r}4IZ zXc~U3)%twon_XU)+vCP`GXz_1W7o4BUV>-pU4}6Ak2W8~M+veW&ecYPp$ez?Y_??H zX-47ssPL)f`BD>LZYc6gl|k@7#U68Gf11?`B>4ptm-`UQ10?qQNS-5g%3cC9T=PVL zvnfoHsf1Zp+GqxIA!82nScv!*!yT%eA$>w5Q{tKlyHfKyBtj~`C$D6l86dO2(ueZ; z4B2w-0_y4oCa(0$R0fr#N{Kqt$zxra9-M3ZV8EG|;VX$iL zUf_C9g**5wA40Wq?1(wsn^{0e6A5~-2695k57QYJ;4JwXJQ rF-Mj}QSVjqI-Vho3`xF5Q3~2Gm + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/samples/multithread/GazStation2/nbproject/genfiles.properties b/java/samples/multithread/GazStation2/nbproject/genfiles.properties new file mode 100644 index 0000000..6f6db25 --- /dev/null +++ b/java/samples/multithread/GazStation2/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=9bff76db +build.xml.script.CRC32=def1c8af +build.xml.stylesheet.CRC32=8064a381@1.80.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=9bff76db +nbproject/build-impl.xml.script.CRC32=4dede8da +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/java/samples/multithread/GazStation2/nbproject/private/private.properties b/java/samples/multithread/GazStation2/nbproject/private/private.properties new file mode 100644 index 0000000..11ff3b8 --- /dev/null +++ b/java/samples/multithread/GazStation2/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=C:\\Users\\denis.LAPTOP-4LI8UQ4O\\AppData\\Roaming\\NetBeans\\8.2\\build.properties diff --git a/java/samples/multithread/GazStation2/nbproject/project.properties b/java/samples/multithread/GazStation2/nbproject/project.properties new file mode 100644 index 0000000..3f0144b --- /dev/null +++ b/java/samples/multithread/GazStation2/nbproject/project.properties @@ -0,0 +1,74 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# \u0424\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 build.classes.dir, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/GazStation2.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=gazstation2.MainClass +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/java/samples/multithread/GazStation2/nbproject/project.xml b/java/samples/multithread/GazStation2/nbproject/project.xml new file mode 100644 index 0000000..7def307 --- /dev/null +++ b/java/samples/multithread/GazStation2/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + GazStation2 + + + + + + + + + diff --git a/java/samples/multithread/GazStation2/src/gazstation2/Car.java b/java/samples/multithread/GazStation2/src/gazstation2/Car.java new file mode 100644 index 0000000..fff0c60 --- /dev/null +++ b/java/samples/multithread/GazStation2/src/gazstation2/Car.java @@ -0,0 +1,43 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package gazstation2; + +import java.util.Random; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author denis + */ +class Car extends Thread{ + public int tank; + private int max = 40; + public String name; + + @Override + public void run() { + for(int i=0 ; i<20 ; i++){ + fuel(); + try {Thread.sleep(1000);} catch (InterruptedException ex) {} + int fuel = new Random().nextInt(40); + tank -= fuel; + System.out.println(name + ": израсходовал " + fuel + " л. Объем топлива: " + tank); + } + } + + public Car(String name) { + this.name = name; + this.tank = new Random().nextInt(max-20); + } + + public void fuel(){ + int fuel = max - tank; + while(!GazStation.getState().column1.getFuel(this, fuel)){ + try {Thread.sleep(2000);} catch (InterruptedException ex) {} + } + } +} diff --git a/java/samples/multithread/GazStation2/src/gazstation2/FilingColumn.java b/java/samples/multithread/GazStation2/src/gazstation2/FilingColumn.java new file mode 100644 index 0000000..80c2f39 --- /dev/null +++ b/java/samples/multithread/GazStation2/src/gazstation2/FilingColumn.java @@ -0,0 +1,49 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package gazstation2; + +import java.util.Random; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author denis + */ +class FilingColumn { + + private int bigTank; + private volatile boolean isOpen; + + public FilingColumn (){ + bigTank = new Random().nextInt(500); + isOpen = true; + } + + public int getBigTank() { + return bigTank; + } + + public synchronized boolean getFuel(Car car, int fuel) { + if(isOpen){ + if(bigTank + + + + + + + + + + Builds, tests, and runs the project MultithreadingExample. + + + diff --git a/java/samples/multithread/MultithreadingExample/build/classes/.netbeans_automatic_build b/java/samples/multithread/MultithreadingExample/build/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/java/samples/multithread/MultithreadingExample/build/classes/.netbeans_update_resources b/java/samples/multithread/MultithreadingExample/build/classes/.netbeans_update_resources new file mode 100644 index 0000000..e69de29 diff --git a/java/samples/multithread/MultithreadingExample/build/classes/multithreadingexample/Bank.class b/java/samples/multithread/MultithreadingExample/build/classes/multithreadingexample/Bank.class new file mode 100644 index 0000000000000000000000000000000000000000..e2339a39cd9eeebd7e41a332dfefe8ccdfb76b42 GIT binary patch literal 495 zcmaJ-$xZ@65Pdzs%&;h%xDYSKi+FG@dV-LkiKmGkFeDzEp#zOWk7;_0ewOh-qKO~i zM;WV;s4>w#)Yet+RlT?O=T`v7Xcpk2;bF4?2aP;(*z&OLVTZxzQIw?0%o!@-l;80n zH8KuDIX7*Fd|!?gH>nm3C%?Ws;Vg}fG!rfONUE{8=d;^b1gBix^gcn`UBYlXQc2Tg z$Q-l=4B4|}L}=wuDshp{hC*NQVN8`;m_$4ta4l`VDrU_@(rUZ^a1n*yiQ*MWp`WBW z66exF=It&=_No$!C^6K(FYIZ}AMBYWc<>pTe_un=Eazgb#=+%qDk6hD6451biNww? zJxE=vFtcQ2*XTbW&&cNv7hsPRI9Mm^E{j!^DYmWDfC{SQebl~&_o>^y;tQPX1u{>_ QS_t+7qDEPrY7RC&03p0>JOBUy literal 0 HcmV?d00001 diff --git a/java/samples/multithread/MultithreadingExample/build/classes/multithreadingexample/BankAccount.class b/java/samples/multithread/MultithreadingExample/build/classes/multithreadingexample/BankAccount.class new file mode 100644 index 0000000000000000000000000000000000000000..af2b43561afac87373dfac037bbe4bb222ba2e25 GIT binary patch literal 985 zcmbtRT~8B16g{*3SS(wM6+vw&6cpN3sSmy>Mo~#>3MPUi`s8*ymWAzZQ)adQ!5`v_ zFD4>J6Mule#9yJFnO37un7EtVx%ck5=bStH_4}tU0B+!V4tZ2GcHi+sg9~Hog8>V?x93$FCxR+;*G{e7O;5 zLsNgSukL#F|&rRQsInI1=^yaP;f+ez-E$!Ayt6~=k`S>V1^I$AVh3&fD{ zx92&Ojpqyz+P%eZdSmMc2~##4!F_B}(^BOhjCD>nwoGFyl&aBKowDwK8=I$P3kyF1 DFIAo5 literal 0 HcmV?d00001 diff --git a/java/samples/multithread/MultithreadingExample/build/classes/multithreadingexample/BankOperation.class b/java/samples/multithread/MultithreadingExample/build/classes/multithreadingexample/BankOperation.class new file mode 100644 index 0000000000000000000000000000000000000000..69f3e554ac0a8a39f2624a199c77bb1b69d5a873 GIT binary patch literal 1589 zcmaJ>TXPge6#iy!y;&wC*%&dXxG`!rw_Q*)7%rLwBbUtv*+3PKlifBMn4Q_0%mgiq zswh_Bo4>&)UP($86iqC7^J(_)_#l2gvz2UsFb{pY&wS_dopZYX`S15_04H%RgMN&3 zA&=2R7{j>0gurA5NsOdXP_mdo0>{eEe!$<0HvI`&MlMJSCDveK-dRpMLz!`zF z8d7IW+w{(9i04PIYe>vFHL0PeWZJUq*O#TcWGq|MWJ^xfu&x`fsm^U>!do@hG`wG` z`<7>VtFAO^roAG+G3pIV7H19n)?!1thG#nVX@+opn;|UvRt|3(>qgNs?3H50b7@9| zFsfC@w>=HRukbk&fr#&}ct-Wsg3$;Q5+ILZ$6YDd(p#2>y;i6=zFUAGf3(qAUR&zm9Tefbwux;h5%y1-{TKF5r}td2RH*D!Q2|8}k#jyz9y z);F!1bTteHzXaQ@?^{1`{WWbqU|z?UxS)0yHB7ZOT6crZ!bAuN zHiHMjR`7&Y4}(8)Cyw*W1&?#VPOwew-PS$+=O5+h5-#f~VL_m*V-Z&bzS40O6%Et7 zK9%cz9+}L8SG!%pWtRM4`n&Dd(7RWF#pRo_$|h&`R9Ai5jwY>tPr0<}I=3V3(Su`X zNVms^jqQyZ>wBhEESYN_n|e5OxU1nDu1E$S$X^`ooPsbX!c#`0A?=!m$$ZD}_K0>` zM5=ZhX(;G+-dC2qOKjF#`vW`=Pkl}7wFWN)afGKmCxUP~^Do9>fQ|}QzFqTVosk@0 zQHc^Yo#GWhKywh{cX^!_z$ujO>gK`5uhB6MtZwwi({pe;X`p9RBe9rODC9*7& zr$?6G;ceW*v9JbX^gIPY%`tNJc6a37u1h!Z?;ywe4AFA|iDwKS7sv`EgetzkyZ<8f WjIa2MS`5=h)%-n5zQkN(_~3syc&(NI literal 0 HcmV?d00001 diff --git a/java/samples/multithread/MultithreadingExample/build/classes/multithreadingexample/MainClass.class b/java/samples/multithread/MultithreadingExample/build/classes/multithreadingexample/MainClass.class new file mode 100644 index 0000000000000000000000000000000000000000..f0fcba09562500a5db73ea3d0df2cbf3e26abb3e GIT binary patch literal 1266 zcmZ`(OHIu!g@S;UA|RzaDo=$X%0tAN0*){!y1KL(8cdT;nm9P)!i5_* zZd~f0kOduO#vkC1ay&O-O2gF7@P7>VL8Mk7ee7(*tC zaZE^hObqL>xSTmz~Irm_09TQY%lQe_mK~IY|uB!Ll^9cJgJyW-4 z>(*S|ny*_64Dz1oSOs-c6V%%3eNG8*1s#Y>c%WbrOVqK*ro0AHS~XR*xn-+G2{{GJ zcqm~-!6Q5-6`G5%#*MeDg@WlAwm@E$u%=)g8w|1QR2YW-kFi@(EpBV3AyA$u*hHKm zv8{1`b7n;?G7L1wsT1`bzI$|{7HnT=?|s!)%XBGBhY|@-bj{2@r+L{lHI`4GYLpj= zw(mfXR&MMyLr-HPFC4=Vci6plA$Ob@L_2*;;uioD^QX0wyez#Ly+fHA*bg_|MQhj% zDoBv6cpK1-9`d5NiC&6OFSLj2DqNlip4@lx8ZsQXM@EIw5A@ROq2;VU5>apckERh;`D z_zNkB4}nPUJ#GF_#n?#&T)LKKcHYdq-8bt$e{Y8X-eb*00gELpp;p8T7t46*;FW{d z424~(r1`)wwXxY^$bX7Ef}s*fCH9i2E%ZKbhlEsv_<)Bku4Niez`Qw>Jq9m`lF&$V zs0Hsx)fLA)ItqpV#jqahZe0n}7F_k}%{b8qA`pEMepD(p+{joF-BR$K z_qiW()%Cyjh1Rkoh{7G$f0pTWX8&>5)7ml|6dk-N<1JPg8uo1T!`|3)dpSDwXmjn^ z-*!OQz~0e!Y41iq?Y$k^3p-3x!_g_FZtcL^cCcE;J9rGM{};tD|9H)@&Sy~bq-R7# z%HzZ^)W(`*?0?fznWmvpMI>r5<9H4;I7ewwNE54VJQ)Uc(R3S|Ev#XhUNl`fP&tZZ zOBDI!8Tsk0Yp`Eg+9g}azzSw)Umh2bpQVUlj+%2>^G-$vl+KZ>PF*4YNZ?Wm^!pT1 UdqPs0kW?l|%x8oPWOJxK0F}k3wg3PC literal 0 HcmV?d00001 diff --git a/java/samples/multithread/MultithreadingExample/manifest.mf b/java/samples/multithread/MultithreadingExample/manifest.mf new file mode 100644 index 0000000..1574df4 --- /dev/null +++ b/java/samples/multithread/MultithreadingExample/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/java/samples/multithread/MultithreadingExample/nbproject/build-impl.xml b/java/samples/multithread/MultithreadingExample/nbproject/build-impl.xml new file mode 100644 index 0000000..78a50db --- /dev/null +++ b/java/samples/multithread/MultithreadingExample/nbproject/build-impl.xml @@ -0,0 +1,1420 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/samples/multithread/MultithreadingExample/nbproject/genfiles.properties b/java/samples/multithread/MultithreadingExample/nbproject/genfiles.properties new file mode 100644 index 0000000..cb81046 --- /dev/null +++ b/java/samples/multithread/MultithreadingExample/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=87dec22c +build.xml.script.CRC32=3cf2961a +build.xml.stylesheet.CRC32=8064a381@1.80.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=87dec22c +nbproject/build-impl.xml.script.CRC32=5ad5c371 +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/java/samples/multithread/MultithreadingExample/nbproject/private/private.properties b/java/samples/multithread/MultithreadingExample/nbproject/private/private.properties new file mode 100644 index 0000000..11ff3b8 --- /dev/null +++ b/java/samples/multithread/MultithreadingExample/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=C:\\Users\\denis.LAPTOP-4LI8UQ4O\\AppData\\Roaming\\NetBeans\\8.2\\build.properties diff --git a/java/samples/multithread/MultithreadingExample/nbproject/private/private.xml b/java/samples/multithread/MultithreadingExample/nbproject/private/private.xml new file mode 100644 index 0000000..1b83c49 --- /dev/null +++ b/java/samples/multithread/MultithreadingExample/nbproject/private/private.xml @@ -0,0 +1,9 @@ + + + + + + file:/C:/Users/denis.LAPTOP-4LI8UQ4O/OneDrive/Документы/NetBeansProjects/MultithreadingExample/src/multithreadingexample/BankOperation.java + + + diff --git a/java/samples/multithread/MultithreadingExample/nbproject/project.properties b/java/samples/multithread/MultithreadingExample/nbproject/project.properties new file mode 100644 index 0000000..99b7f0f --- /dev/null +++ b/java/samples/multithread/MultithreadingExample/nbproject/project.properties @@ -0,0 +1,74 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# \u0424\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 build.classes.dir, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/MultithreadingExample.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=multithreadingexample.MainClass +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/java/samples/multithread/MultithreadingExample/nbproject/project.xml b/java/samples/multithread/MultithreadingExample/nbproject/project.xml new file mode 100644 index 0000000..62686c4 --- /dev/null +++ b/java/samples/multithread/MultithreadingExample/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + MultithreadingExample + + + + + + + + + diff --git a/java/samples/multithread/MultithreadingExample/src/multithreadingexample/Bank.java b/java/samples/multithread/MultithreadingExample/src/multithreadingexample/Bank.java new file mode 100644 index 0000000..fd50d10 --- /dev/null +++ b/java/samples/multithread/MultithreadingExample/src/multithreadingexample/Bank.java @@ -0,0 +1,19 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package multithreadingexample; + +import java.util.ArrayList; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +/** + * + * @author denis + */ +public class Bank { + public static List accounts = new ArrayList<>(); +} diff --git a/java/samples/multithread/MultithreadingExample/src/multithreadingexample/BankAccount.java b/java/samples/multithread/MultithreadingExample/src/multithreadingexample/BankAccount.java new file mode 100644 index 0000000..992eacd --- /dev/null +++ b/java/samples/multithread/MultithreadingExample/src/multithreadingexample/BankAccount.java @@ -0,0 +1,44 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package multithreadingexample; + +import java.util.Random; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author denis + */ +public class BankAccount { + private int number; + private int fund; + + public BankAccount(int fund) { + this.number = new Random().nextInt(1000000); + this.fund = fund; + } + + public int getFund() { + return fund; + } + + public int fundUp(int summ){ + int fund = this.fund; + try {Thread.sleep(1000);} catch (InterruptedException ex) {} + fund += summ; + this.fund = fund; + return this.fund; + } + + public int fundDown(int summ){ + int fund = this.fund; + try {Thread.sleep(1000);} catch (InterruptedException ex) {} + fund -= summ; + this.fund = fund; + return this.fund; + } +} diff --git a/java/samples/multithread/MultithreadingExample/src/multithreadingexample/BankOperation.java b/java/samples/multithread/MultithreadingExample/src/multithreadingexample/BankOperation.java new file mode 100644 index 0000000..40ed15c --- /dev/null +++ b/java/samples/multithread/MultithreadingExample/src/multithreadingexample/BankOperation.java @@ -0,0 +1,32 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package multithreadingexample; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author denis + */ +public class BankOperation implements Runnable{ + + @Override + public void run() { + BankAccount account = Bank.accounts.get(0); + + synchronized (account){ + String line = "Состояние до: " + account.getFund() + "руб., добавляем 10000 и получаем: " + account.fundUp(10000); + System.out.println(line); + } + + synchronized (account){ + String line = "Состояние до: " + account.getFund() + "руб., убавляем на 10000 и получаем: " + account.fundDown(10000); + System.out.println(line); + } + } + +} diff --git a/java/samples/multithread/MultithreadingExample/src/multithreadingexample/MainClass.java b/java/samples/multithread/MultithreadingExample/src/multithreadingexample/MainClass.java new file mode 100644 index 0000000..3f94bb9 --- /dev/null +++ b/java/samples/multithread/MultithreadingExample/src/multithreadingexample/MainClass.java @@ -0,0 +1,38 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package multithreadingexample; + +/** + * + * @author denis + */ +public class MainClass { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + System.out.println("Main thread is started"); + + Bank.accounts.add(new BankAccount(10000)); + + Thread thread1 = new Thread(new BankOperation()); + Thread thread2 = new Thread(new BankOperation()); + Thread thread3 = new Thread(new BankOperation()); + Thread thread4 = new Thread(new BankOperation()); + Thread thread5 = new Thread(new BankOperation()); + Thread thread6 = new Thread(new BankOperation()); + thread1.start(); + thread2.start(); + thread3.start(); + thread4.start(); + thread5.start(); + thread6.start(); + + System.out.println("Mian thread is stoped"); + } + +} diff --git a/java/samples/multithread/MultithreadingExample/src/multithreadingexample/MyThread.java b/java/samples/multithread/MultithreadingExample/src/multithreadingexample/MyThread.java new file mode 100644 index 0000000..974f959 --- /dev/null +++ b/java/samples/multithread/MultithreadingExample/src/multithreadingexample/MyThread.java @@ -0,0 +1,24 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package multithreadingexample; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author denis + */ +public class MyThread extends Thread{ + + @Override + public void run() { + //Thread.sleep(5000); + System.out.println("Привет из параллельного потака 1"); + } + + +} diff --git a/java/samples/multithread/MultithreadingExample_2/build.xml b/java/samples/multithread/MultithreadingExample_2/build.xml new file mode 100644 index 0000000..45caa65 --- /dev/null +++ b/java/samples/multithread/MultithreadingExample_2/build.xml @@ -0,0 +1,73 @@ + + + + + + + + + + + Builds, tests, and runs the project MultithreadingExample_2. + + + diff --git a/java/samples/multithread/MultithreadingExample_2/build/classes/.netbeans_automatic_build b/java/samples/multithread/MultithreadingExample_2/build/classes/.netbeans_automatic_build new file mode 100644 index 0000000..e69de29 diff --git a/java/samples/multithread/MultithreadingExample_2/build/classes/.netbeans_update_resources b/java/samples/multithread/MultithreadingExample_2/build/classes/.netbeans_update_resources new file mode 100644 index 0000000..e69de29 diff --git a/java/samples/multithread/MultithreadingExample_2/build/classes/multithreadingexample_2/Bank.class b/java/samples/multithread/MultithreadingExample_2/build/classes/multithreadingexample_2/Bank.class new file mode 100644 index 0000000000000000000000000000000000000000..f4bbf3bdf70c8e428616a7441401afc06bee39e5 GIT binary patch literal 501 zcmaJ-T}uK%6g{)*?)p)hW?w`Qy;Kh^M9_mGSkTi_4~EcFjO(Cd<8F+zQ9mns5DNMM z{ix`UNktFN!~L3j&$;(}e7?Q|IKfr{F6tiE3UE-*BZqYl8y+?pd>%zf8k-42B^>bw z9;8O9Ae0l+V90mmAm%33g5mVvcQYKP%1ATRg7;-S5RZI(uf*+faK_`i_BU*!MJR4l z#?rJHGW!QzhU|ILC%kefV{w^|dqQ9Ho}x-MOd_tjTuYnJi&-<2wA{`@HX`wxk($#K zI!US{aUm^e-fnYbFDs#l5<~6x%C^@0$(~w*2cKbk(M2TCY*O)f5M1>}A~M(|DP5A7 zXe`3agEY1}GfPKyiT(rfjC}5J3ieEagJrVrtXM{wV%tg$s9=S>kLu6x9(CJSe1mf{ TMdk%r3&H+CR4A)a&B5vyf-i3I literal 0 HcmV?d00001 diff --git a/java/samples/multithread/MultithreadingExample_2/build/classes/multithreadingexample_2/BankAccount.class b/java/samples/multithread/MultithreadingExample_2/build/classes/multithreadingexample_2/BankAccount.class new file mode 100644 index 0000000000000000000000000000000000000000..de2a1fe97968061c824b0f0f7dab254d582b1598 GIT binary patch literal 789 zcma)2?`zXg6g@9#nzf5|w$3>lx7Kai<%0q7n@)7fpimV2F;EbFO=6dsyo@f<{ZW1q zoC5{_0RJfQyrhbL7>vMu_uia)&bjyJuWvs9+{Q)|4Y)S0HetXu(b~SRvy}$su&P7P zM&HIYfx0TvaWoYWLxI}6LWS(zja8iAV?7vd?(%tnYen-HbMEOoBYYsN) zp{_l=IH<(6r^6ym1?F`7QT9;@G@oU~G>CR$ZDHXbwwwF%gLH5XYwYXXFY-9?pGp;G zse^SaIcQ?ufrEL0wKMqp!;?rg@t=(MqaYWcPaefq(NR8BIr=1djJnr7hW)vmU0`f;wu&8GL0PMKRXnm%clX2Y+EHi_%#;VrlOcFS|= z?0>4toeK*q+-%}e^6#i}!vLRh41S&y4FgH-Bs1B2&pF@u&X0TUefjTi`vA`2Rvf(; zZbuI??HED!7;+d@Fs5KUjwps>IP0(H;%LK%{_dj~&ildzU--Bk6Sx@1C43UYq_4iL z;8O)t3Z@03dS%IQD+1ycg-g1rJCg$8)X=Ix|^ZDHq(*y0llcb%UBj-YRIu zs%GoHe4vatn>u+0^Cj1CbZ66+T2VJQY{;+2bJLo6XR$18&CxCMB7@kjDbQw+ zeaz>)t!-&JLo+vW%Z^P?LIUHsfT9%&mTNi!XIj!v)nWAPSa!6+oq4SsWT)VYz-i0g z$ePkwmzr70E?cf$ka@W!jVaT#oFFUa-`kMK;+C{+y(q~Suj6O+p#G*(vVP(!PNHAM z8|YIoqv9%N6hwBX7sv`#}3-rBO|Fo+cMQIE4d%t-5wR^Su{Ql(q;XU>ClHOx) zekGkmThk9mK$AaK6+L+ydLlg$JGZ^wJ&?RwAXwdehw92?~?={-$)&%J$WAJl%N zofe;H5lbq*zzqe#K>eGwWeLe5)Z9a0}e+*pzEjwi|e;# zf#;n#Qr&P(vp#=4N6M8=+uE*c2U#XIY}Zc=Q`$ZoHTC~E4A9WSwZZ)UTad6s>U!3%og zbrte;i213_SlcGv<;&CyBKa5o72vBC;*K|h-!~~;2xK6hegct>>>;!hVBX?4P8*;i zf=&zsI}vD4;cc!0?~o@!5yo& zs%RgsB3{L@gzE3R2fM21pjbuc!Y+=FRMGViqp!nvAL0|u_{@ukh)+Z^FZv_TcbHK( zwsDu)+{O378irp@n)Lt)bg(1c?8r&>W0D=Y%H13*F5G5eRRbYtU5Yqnv@OHWfl6#k~KY3o%A6%|Fiib4Ugf{F+}K~S`%DvCi9%}}mzwY??ntFaL&0;t%F&Kw|6M7knVp!s_NuN!zjA(*nU%*R()rv@~Z4 zG-PbYnyeOQt@3p>TcD&VQ_8Etv?|-0UloSj1-l~9mnl{YuI(KS4WHo@a>U24({B(xO#X zu3d8a1Ul_hM&m8eHNBzt(KQkb(dCFD!2U)e~;ULjQ{Zy%1&RgTQ z2CKDB-G_9k2AYtRIBnnz&I&YU34~e0&aAkq>`I(7FoIEu^9IH+F3?^NUtQU`e7;n5 zT$$H}`MMan z+51-BT_>7)Tyd=;r?6C|qPaE`b}4;@1L1NkELCLVl3t$c#R76s8x=TB&8dxtskL6V z8b5)kszJy(OVk`xUAvIZ*cDe#YHC6cU2_n+=4o$jVnw_7ZACkFBZW4;dV4Sk6Q>B`IQAh&%?<3w9UQ;{I#59;p3w3c zy6^(sc*RHa9d#f0Xs!@ojo~$VRa~`SsS%^^Hty|sN$)1{JdEe`Z?Zjuc*-ayvl_=k sT9`yRhaw}I2s5gVYqCQfJiiZtUvwOm=#+^4^Ao@iT&3?6Ed%KK4aPx# literal 0 HcmV?d00001 diff --git a/java/samples/multithread/MultithreadingExample_2/build/classes/multithreadingexample_2/MyThread1.class b/java/samples/multithread/MultithreadingExample_2/build/classes/multithreadingexample_2/MyThread1.class new file mode 100644 index 0000000000000000000000000000000000000000..980d2d2d2dc88b27fddf58e6f503e854b75f5f24 GIT binary patch literal 1172 zcmah}O;Zy=5PcJp3|W^DL-HtydWOax*&&(Slo(41*0kb zI21{j+^TSPgl7l)PB5x>?G{6})bJf`>s?QZnyu>cKs1_;{IFoHA8v=i`6VLoe8muv z2MklCJ+Ut=N2t2>MrrAJepAa@@t`W3+IAIX50tg2eq0yL4pr9m>Ukw~MGDo*mtEhh z%97ld&Z<(b76FPn$#fOo+^4#BO;RzVoxf%WH%b0&Dj#%VB8AHw3nm_5k>jC>M|e#9 zoyMnHT6mh{iHWCp#xVKs&KaivI}45_6U%tcv0~x{UUICOc!h$A*C;Zi&KNc;d$Ou& z_-COlU#YetU3u+Z8DcF*$|k9pdmD(^l~F!yY1tqVT%YO4W9K^a72rQ;B~1tM1#hi$<15@F^q)}U)zr5xb-?! zvPxv7$B-cGA3xuVv0bkRmaZ_`qi*m_=%ts7JH;&;@OUqLkVEi3YKEcEVLeX~rd+&B zSA=wMKLzU0R4|PMeVsHM`ZgnE>6y`*rkzEWk&VrM1v?6lhiHw5!9irmH`@sq#t7}` zS_F=S;LnJX2V^sdoFaORSUP?J{)OItI&lKy6qk-+vbhrs9EC-a1noy30*VPD0TINh ya1vv5GD1a1=`UkEq#X%KQgkvNVzZqFCJ4n5dC$?G!WG&Cy`U>pQNd_N#=&;^qa6Bim2W8!LjBoMZyKm#>19a1_(KT8*yxbOq~ zDC3=hsI2Vb-rm!5&wcds>-_`3F={q4DCe+>N)~H2*0Et>)4~=*=1eMS&KVZ!haHCW zW!M)C1y3q*69rwN+q~-&Qu4wc_d8t6IG%xNGn8Y7122etBh63?-j`}19(geG#eLJg zerhLR^OOqcND(*GgN72OE4UgrT4AJn!V?qWUnmtCZe*xPan*a^6Ylz44cyy_&|3Bd zN!U~Vm5e)D{t<7)WCs?q7PcMiV3#33D_k8Lu8oB~2m7cp)c$Riq4-;Tsxk+)p2kK5 zG*1{AhRU>48M=2`D$_EwgMeBsCmQoGgEfjtKJB4W|1% + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + java -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/java/samples/multithread/MultithreadingExample_2/nbproject/genfiles.properties b/java/samples/multithread/MultithreadingExample_2/nbproject/genfiles.properties new file mode 100644 index 0000000..4564d2a --- /dev/null +++ b/java/samples/multithread/MultithreadingExample_2/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=33ff94e6 +build.xml.script.CRC32=c811e3e8 +build.xml.stylesheet.CRC32=8064a381@1.80.1.48 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=33ff94e6 +nbproject/build-impl.xml.script.CRC32=01054350 +nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48 diff --git a/java/samples/multithread/MultithreadingExample_2/nbproject/private/private.properties b/java/samples/multithread/MultithreadingExample_2/nbproject/private/private.properties new file mode 100644 index 0000000..11ff3b8 --- /dev/null +++ b/java/samples/multithread/MultithreadingExample_2/nbproject/private/private.properties @@ -0,0 +1,2 @@ +compile.on.save=true +user.properties.file=C:\\Users\\denis.LAPTOP-4LI8UQ4O\\AppData\\Roaming\\NetBeans\\8.2\\build.properties diff --git a/java/samples/multithread/MultithreadingExample_2/nbproject/project.properties b/java/samples/multithread/MultithreadingExample_2/nbproject/project.properties new file mode 100644 index 0000000..25ce47e --- /dev/null +++ b/java/samples/multithread/MultithreadingExample_2/nbproject/project.properties @@ -0,0 +1,74 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processor.options= +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# \u0424\u0430\u0439\u043b\u044b \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 build.classes.dir, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0438\u0437 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u044f\u0435\u043c\u043e\u0433\u043e \u0430\u0440\u0445\u0438\u0432\u0430 jar +dist.archive.excludes= +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/MultithreadingExample_2.jar +dist.javadoc.dir=${dist.dir}/javadoc +excludes= +includes=** +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.external.vm=true +javac.processorpath=\ + ${javac.classpath} +javac.source=1.8 +javac.target=1.8 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=false +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +main.class=multithreadingexample_2.MultithreadingExample_2 +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project. +# You may also define separate properties like run-sys-prop.name=value instead of -Dname=value. +# To set system properties for unit tests define test-sys-prop.name=value: +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +src.dir=src +test.src.dir=test diff --git a/java/samples/multithread/MultithreadingExample_2/nbproject/project.xml b/java/samples/multithread/MultithreadingExample_2/nbproject/project.xml new file mode 100644 index 0000000..ec5ae3f --- /dev/null +++ b/java/samples/multithread/MultithreadingExample_2/nbproject/project.xml @@ -0,0 +1,15 @@ + + + org.netbeans.modules.java.j2seproject + + + MultithreadingExample_2 + + + + + + + + + diff --git a/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/Bank.java b/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/Bank.java new file mode 100644 index 0000000..05985c1 --- /dev/null +++ b/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/Bank.java @@ -0,0 +1,17 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package multithreadingexample_2; + +import java.util.ArrayList; +import java.util.List; + +/** + * + * @author denis + */ +public class Bank { + public static List accounts = new ArrayList<>(); +} diff --git a/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/BankAccount.java b/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/BankAccount.java new file mode 100644 index 0000000..1187005 --- /dev/null +++ b/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/BankAccount.java @@ -0,0 +1,42 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package multithreadingexample_2; + +import java.util.Random; + +/** + * + * @author denis + */ +public class BankAccount { + private int number; + private int fund; + + public BankAccount(int fund) { + this.number = new Random().nextInt(1000000); + this.fund = fund; + } + + public int getFund() { + return fund; + } + + public synchronized int fundUp(int summ){ + int fund = this.fund; + //try {Thread.sleep(10);} catch (InterruptedException ex) {} + fund += summ; + this.fund = fund; + return this.fund; + } + + public synchronized int fundDown(int summ){ + int fund = this.fund; + //try {Thread.sleep(10);} catch (InterruptedException ex) {} + fund -= summ; + this.fund = fund; + return this.fund; + } +} diff --git a/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/BankOperation.java b/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/BankOperation.java new file mode 100644 index 0000000..a40d225 --- /dev/null +++ b/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/BankOperation.java @@ -0,0 +1,30 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package multithreadingexample_2; + +/** + * + * @author denis + */ +public class BankOperation implements Runnable{ + + public boolean isPlus = true; + + @Override + public void run() { + BankAccount account = Bank.accounts.get(0); + + synchronized (account){ + if(isPlus){ + String line1 = "Состояние до: " + account.getFund() + "руб., добавляем 10000 и получаем: " + account.fundUp(10000); + System.out.println(line1); + }else{ + String line2 = "Состояние до: " + account.getFund() + "руб., убавляем на 10000 и получаем: " + account.fundDown(10000); + System.out.println(line2); + } + } + } +} diff --git a/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/MultithreadingExample_2.java b/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/MultithreadingExample_2.java new file mode 100644 index 0000000..fc519e0 --- /dev/null +++ b/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/MultithreadingExample_2.java @@ -0,0 +1,49 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package multithreadingexample_2; + +/** + * + * @author denis + */ +public class MultithreadingExample_2 { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + System.out.println("Main thread start"); +// MyThread1 thread1 = new MyThread1(); +// Thread thread = new Thread(thread1); +// thread.start(); +// +// MyThread2 thread2 = new MyThread2(); +// thread2.start(); + + + Bank.accounts.add(new BankAccount(10000)); + BankOperation operation1 = new BankOperation(); + operation1.isPlus = false; + BankOperation operation2 = new BankOperation(); + BankOperation operation3 = new BankOperation(); + operation3.isPlus = false; + BankOperation operation4 = new BankOperation(); + BankOperation operation5 = new BankOperation(); + operation5.isPlus = false; + BankOperation operation6 = new BankOperation(); + for(int i=0 ; i<50 ; i++){ + new Thread(operation1).start(); + new Thread(operation2).start(); + new Thread(operation3).start(); + new Thread(operation4).start(); + new Thread(operation5).start(); + new Thread(operation6).start(); + } + + System.out.println("Main thread finish"); + } + +} diff --git a/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/MyThread1.java b/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/MyThread1.java new file mode 100644 index 0000000..d432019 --- /dev/null +++ b/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/MyThread1.java @@ -0,0 +1,27 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package multithreadingexample_2; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * + * @author denis + */ +public class MyThread1 implements Runnable{ + + @Override + public void run() { + try { + Thread.sleep(500); + System.out.println("Thread1 start"); + } catch (InterruptedException ex) { + Logger.getLogger(MyThread1.class.getName()).log(Level.SEVERE, null, ex); + } + } + +} diff --git a/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/MyThread2.java b/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/MyThread2.java new file mode 100644 index 0000000..e1ff087 --- /dev/null +++ b/java/samples/multithread/MultithreadingExample_2/src/multithreadingexample_2/MyThread2.java @@ -0,0 +1,19 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package multithreadingexample_2; + +/** + * + * @author denis + */ +public class MyThread2 extends Thread{ + + @Override + public void run() { + System.out.println("Thread2 start"); + } + +}