From c0ac39b3f16d495eccafb767ef547341d5a9f15f Mon Sep 17 00:00:00 2001 From: guide Date: Wed, 24 Feb 2021 22:29:42 +0800 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ThreadPoolExecutorDemo/.idea/.gitignore | 2 - .../.idea/checkstyle-idea.xml | 16 --- .../inspectionProfiles/Project_Default.xml | 36 ----- .../ThreadPoolExecutorDemo/.idea/misc.xml | 6 - .../ThreadPoolExecutorDemo/.idea/modules.xml | 8 -- .../.idea/uiDesigner.xml | 124 ------------------ .../java/ThreadPoolExecutorDemo/.idea/vcs.xml | 6 - .../ThreadPoolExecutorDemo.iml | 11 -- .../ThreadPoolExecutorDemo.kotlin_module | Bin 16 -> 0 bytes .../callable/CallableDemo.class | Bin 2828 -> 0 bytes .../callable/MyCallable.class | Bin 782 -> 0 bytes .../common/ThreadPoolConstants.class | Bin 607 -> 0 bytes .../ScheduledThreadPoolExecutorDemo.class | Bin 1935 -> 0 bytes .../scheduledThreadPoolExecutor/Task.class | Bin 1307 -> 0 bytes .../threadPoolExecutor/MyRunnable.class | Bin 1406 -> 0 bytes .../ThreadPoolExecutorDemo.class | Bin 1816 -> 0 bytes .../src/callable/CallableDemo.java | 49 ------- .../src/callable/MyCallable.java | 13 -- .../src/common/ThreadPoolConstants.java | 11 -- .../src/threadPoolExecutor/MyRunnable.java | 36 ----- .../ThreadPoolExecutorDemo.java | 39 ------ 21 files changed, 357 deletions(-) delete mode 100644 code/java/ThreadPoolExecutorDemo/.idea/.gitignore delete mode 100644 code/java/ThreadPoolExecutorDemo/.idea/checkstyle-idea.xml delete mode 100644 code/java/ThreadPoolExecutorDemo/.idea/inspectionProfiles/Project_Default.xml delete mode 100644 code/java/ThreadPoolExecutorDemo/.idea/misc.xml delete mode 100644 code/java/ThreadPoolExecutorDemo/.idea/modules.xml delete mode 100644 code/java/ThreadPoolExecutorDemo/.idea/uiDesigner.xml delete mode 100644 code/java/ThreadPoolExecutorDemo/.idea/vcs.xml delete mode 100644 code/java/ThreadPoolExecutorDemo/ThreadPoolExecutorDemo.iml delete mode 100644 code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/META-INF/ThreadPoolExecutorDemo.kotlin_module delete mode 100644 code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/callable/CallableDemo.class delete mode 100644 code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/callable/MyCallable.class delete mode 100644 code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/common/ThreadPoolConstants.class delete mode 100644 code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/scheduledThreadPoolExecutor/ScheduledThreadPoolExecutorDemo.class delete mode 100644 code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/scheduledThreadPoolExecutor/Task.class delete mode 100644 code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/threadPoolExecutor/MyRunnable.class delete mode 100644 code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/threadPoolExecutor/ThreadPoolExecutorDemo.class delete mode 100644 code/java/ThreadPoolExecutorDemo/src/callable/CallableDemo.java delete mode 100644 code/java/ThreadPoolExecutorDemo/src/callable/MyCallable.java delete mode 100644 code/java/ThreadPoolExecutorDemo/src/common/ThreadPoolConstants.java delete mode 100644 code/java/ThreadPoolExecutorDemo/src/threadPoolExecutor/MyRunnable.java delete mode 100644 code/java/ThreadPoolExecutorDemo/src/threadPoolExecutor/ThreadPoolExecutorDemo.java diff --git a/code/java/ThreadPoolExecutorDemo/.idea/.gitignore b/code/java/ThreadPoolExecutorDemo/.idea/.gitignore deleted file mode 100644 index 5c98b428..00000000 --- a/code/java/ThreadPoolExecutorDemo/.idea/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# Default ignored files -/workspace.xml \ No newline at end of file diff --git a/code/java/ThreadPoolExecutorDemo/.idea/checkstyle-idea.xml b/code/java/ThreadPoolExecutorDemo/.idea/checkstyle-idea.xml deleted file mode 100644 index e61c523d..00000000 --- a/code/java/ThreadPoolExecutorDemo/.idea/checkstyle-idea.xml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/code/java/ThreadPoolExecutorDemo/.idea/inspectionProfiles/Project_Default.xml b/code/java/ThreadPoolExecutorDemo/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 6560a989..00000000 --- a/code/java/ThreadPoolExecutorDemo/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,36 +0,0 @@ - - - - \ No newline at end of file diff --git a/code/java/ThreadPoolExecutorDemo/.idea/misc.xml b/code/java/ThreadPoolExecutorDemo/.idea/misc.xml deleted file mode 100644 index 05483570..00000000 --- a/code/java/ThreadPoolExecutorDemo/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/code/java/ThreadPoolExecutorDemo/.idea/modules.xml b/code/java/ThreadPoolExecutorDemo/.idea/modules.xml deleted file mode 100644 index 864cd10e..00000000 --- a/code/java/ThreadPoolExecutorDemo/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/code/java/ThreadPoolExecutorDemo/.idea/uiDesigner.xml b/code/java/ThreadPoolExecutorDemo/.idea/uiDesigner.xml deleted file mode 100644 index e96534fb..00000000 --- a/code/java/ThreadPoolExecutorDemo/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/code/java/ThreadPoolExecutorDemo/.idea/vcs.xml b/code/java/ThreadPoolExecutorDemo/.idea/vcs.xml deleted file mode 100644 index c2365ab1..00000000 --- a/code/java/ThreadPoolExecutorDemo/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/code/java/ThreadPoolExecutorDemo/ThreadPoolExecutorDemo.iml b/code/java/ThreadPoolExecutorDemo/ThreadPoolExecutorDemo.iml deleted file mode 100644 index c90834f2..00000000 --- a/code/java/ThreadPoolExecutorDemo/ThreadPoolExecutorDemo.iml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/META-INF/ThreadPoolExecutorDemo.kotlin_module b/code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/META-INF/ThreadPoolExecutorDemo.kotlin_module deleted file mode 100644 index 2983af70661ad375cc499ebc4da5a68ca46c532e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 16 RcmZQzU|?ooU|@t|egFVe02KfL diff --git a/code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/callable/CallableDemo.class b/code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/callable/CallableDemo.class deleted file mode 100644 index 70861e733a47200649939b884b11f155471af1fc..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2828 zcma)8YjYGu6g`t{wzHD~LLi9&!b77Z5Qqr!NHChmA`6=bNeBj1oa_$C!0t?(orOg4 zjc+!zzCSWf@P;?Cb+KmRq&cJ>BP?d;9e5+w=S1zx)bd z555r?RIwF90>cp~IHqC*qY;eZxWKpyffE9csfb`mMI}xNJg!2M@F!HP^ar1;!D&1t zA9@WYk&ut1fDyqNObJY@Xp{z~iY95$h_lr=C)-pF>X8<(-K+4Q90jOmjpj?~5Ngq|AL9aFyN21D+& znNiRf=Tu6Lcl6~t{YKjEB3)WHEd>p&r{ZVz^Lj^0x28HqUB|Shx}>}CnXH?2NZ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aq3RoI7S>?Ti$*eX1Tz0}v?bDuX${jeVgXw`zt z=tLLQZO0`X#6yg84=&RC!~CXugothA@OgX4PG9ci;Cu-NUL36%EZkrJr)b)=5di=j$RfrUiWhcXP6&RLP z2YMVylO_~#aEm7|$dJ_N&=2A$NRvcG#=jP^d#fQIyk|!b;xq}=p|+dV3(fDWOb-v? zIoR~Dg*P6$=y}*i%R>__f!2Rk6=)RuWx52`=Fok@NK~}kT*Mus(@CP_NT56omAd3@ zc8}~Is^vRgr|;fwhH^z`tjw{zQ0VZ7SHYd_YoOZIlxL`XC6JN0^x)hI=M_Y?oT$xQiS0{`52SpO ZQxj%3rOjpW*-j diff --git a/code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/common/ThreadPoolConstants.class b/code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/common/ThreadPoolConstants.class deleted file mode 100644 index 07214fc7233b0d7fe676bdba09a2c83d98b66e01..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 607 zcmZ`$%TB^T6g>llYOSK;1K+QWxR8bJG$y2}Nwr#3Bj+HKYSc9qvdVkT|j@vz3* zfy8}MiJL)(VbS(Pt0kgRwb}N0qasB36}>|(hW5R%-$c6*-L~f+2GX+dhkRQG)G>|; z6{|Ydu&!eaIfnWFThLsCv7Gw7@5Qu|0VOA8P~``1 diff --git a/code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/scheduledThreadPoolExecutor/ScheduledThreadPoolExecutorDemo.class b/code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/scheduledThreadPoolExecutor/ScheduledThreadPoolExecutorDemo.class deleted file mode 100644 index dc98bc8f2fec1837f53224a6cbc7d0327296b4bb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1935 zcmb7FZC4vb6n+L0c3HNBLIS4RlD?<`3K2xBq^-6Dlp0=a(nf5xPIgDKknHAcW=s7= zel8z^$T|K1f0TM>Lry{)iEgqxGk2c3FVEb$^XFf`{{dhbRRdRX$G~U!T*Hcvtbsw? z)p2ha_wj{>FAeCpqvL^UA8J@NU@E+hocgR8SjSgUQl*~gFuumd2p-{^w#ZPTyb^6{ z*fNmBwi@hc_*TPXhM~KT>&W{IgXx*443SmO77VexHWeU=F+`X)Fijn;h0OiNWD zoodGNTr2Q>;mVGmZO;qBf9Y6)G)E2xG>Nnf!g3DhD!y>t%FTo56RLntD!(! zOuN8f6uiK<#JZ!Xz14@I1x1R9YnawhH1PyPN$MiTl_Lxzirtjzrxw-f(mBzRhVM-5 z;(LavH%WgOI8|Ht45P)0NJ*zAQcfeak}~lO&q*5ML;7-D3MKu)#E*EP;U^OuB@Ja0 z7HkUGguu@x_F$W+z+t%7G1hAvP3&XZ!~v!mvKPhJhckw;j-l=HzOW?2e8=(suC9j4xg|wPxhGVX2w7NL-QLO-7^Zvk*@luWy`3)%&$|PE9JsD3TG>Z^RP@`j^*{!` zst1wWgI#iIj307G7KLAPT&{``!_9PGBXr_oVf6@ZahFV5#boLnRbvS*UzC)o<#|`S6EdXxf7LA7SK0Y8x3SbFD=?B!KzhNMM zioxCS$T6auVQ+|fTSw4Nq3<4Jc-&}W)}cm+cK@N>HQFCL{uc0!7Q~=sugp%O?F~bdgie}v?Wm@x)#Xd fM}$aX;BQhH(Xgn2%HGHH2h*^usQZKf1NihGgDC|t diff --git a/code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/scheduledThreadPoolExecutor/Task.class b/code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/scheduledThreadPoolExecutor/Task.class deleted file mode 100644 index 9920a634de1d64a9b3815145f4ad5110e6ce61a4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1307 zcmah}YfsZq7=F&!=vK?7+(Zzph&n(vLBtCe6&MPROJpJOi=?zCQ0Us(of`Z_eifsG zNMii#FY#9x-_wpTgv2E~?R$IP+jIKs&-Why#<8ZN6T>NV;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ThreadPoolExecutorDemo/threadPoolExecutor/ThreadPoolExecutorDemo.class b/code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/threadPoolExecutor/ThreadPoolExecutorDemo.class deleted file mode 100644 index 80c34f4d66e543a86bfb30522744943587029477..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1816 zcma)6UsoGN6#oqg+3dQ|2nDo&MXfY|Z4|3kX{!(d4GoZzG@4eW!|q5HHandCW6Qgr z!be~FEDy;!<{UqOU%=1cN6>S$-bv^w$kv*3a%bnxoqK=x{_dS$|Ni+G0N1dm;e7++ znAh-u4u)$6KEy{lKE`zopBT{asfGmuI_3=|a7)8y8a_8LfcZ2Q)w-laUWsJ`CJM@I zMTu1F26vRLi0%7brxNJ08Pm_CaZnf5&q! z_jYrY(09Du1qC7XNc#K2XE=Z2d@J%i6`1ZbhyF$K!~Iq|Gfc)1zkc|PEQYavGrSZzuC2(W{=AO| zN_=JFYkZ?1Z<}}sZej z&mnE@>G-C`}rI6p;SgtT!d_hkho2n_v7S%93&K8SnFENfkKGhHl@itpR6+qa%p>?Ep zn|n5OLT?WF!GZ8>hAY|L?Nft#Ms>_AL7yP#|8blSWpCPv*6dkBaxfAXkcy%8hMMX< zcGBWmyLC~ggGLnE@)5l-rV~_!-*h}qDRw!!e~SLfVGxQY9mt5t8R(xgOrc1$wj9uaDkr8gi0v&@M+SbvgQH+vxkLdwh{(s;eBp6n&dL z19I^e?R312OQcbke}{o2txgAtdOBkqA=yIz5mFs!^^Dy{x&yu5hSA0=rNqsNjPWC8 zIxy=U43K(o=v)h#i56aMVW^Gajkzl=od3R$J$d@uTni)gAN>KTCr|%4!r0JjExfJ( zCZGV$QfOe9ufK~_5XxdHtjH(%u0 diff --git a/code/java/ThreadPoolExecutorDemo/src/callable/CallableDemo.java b/code/java/ThreadPoolExecutorDemo/src/callable/CallableDemo.java deleted file mode 100644 index be762bda..00000000 --- a/code/java/ThreadPoolExecutorDemo/src/callable/CallableDemo.java +++ /dev/null @@ -1,49 +0,0 @@ -package callable; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.Callable; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.Future; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import static common.ThreadPoolConstants.CORE_POOL_SIZE; -import static common.ThreadPoolConstants.KEEP_ALIVE_TIME; -import static common.ThreadPoolConstants.MAX_POOL_SIZE; -import static common.ThreadPoolConstants.QUEUE_CAPACITY; - -public class CallableDemo { - public static void main(String[] args) { - //使用阿里巴巴推荐的创建线程池的方式 - //通过ThreadPoolExecutor构造函数自定义参数创建 - ThreadPoolExecutor executor = new ThreadPoolExecutor( - CORE_POOL_SIZE, - MAX_POOL_SIZE, - KEEP_ALIVE_TIME, - TimeUnit.SECONDS, - new ArrayBlockingQueue<>(QUEUE_CAPACITY), - new ThreadPoolExecutor.CallerRunsPolicy()); - - List> futureList = new ArrayList<>(); - Callable callable = new MyCallable(); - for (int i = 0; i < 10; i++) { - //提交任务到线程池 - Future future = executor.submit(callable); - //将返回值 future 添加到 list,我们可以通过 future 获得 执行 Callable 得到的返回值 - futureList.add(future); - } - for (Future fut : futureList) { - try { - System.out.println(new Date() + "::" + fut.get()); - } catch (InterruptedException | ExecutionException e) { - e.printStackTrace(); - } - } - //关闭线程池 - executor.shutdown(); - } -} - diff --git a/code/java/ThreadPoolExecutorDemo/src/callable/MyCallable.java b/code/java/ThreadPoolExecutorDemo/src/callable/MyCallable.java deleted file mode 100644 index 53d540fb..00000000 --- a/code/java/ThreadPoolExecutorDemo/src/callable/MyCallable.java +++ /dev/null @@ -1,13 +0,0 @@ -package callable; - -import java.util.concurrent.Callable; - -public class MyCallable implements Callable { - - @Override - public String call() throws Exception { - Thread.sleep(1000); - //返回执行当前 Callable 的线程名字 - return Thread.currentThread().getName(); - } -} diff --git a/code/java/ThreadPoolExecutorDemo/src/common/ThreadPoolConstants.java b/code/java/ThreadPoolExecutorDemo/src/common/ThreadPoolConstants.java deleted file mode 100644 index 2018e86f..00000000 --- a/code/java/ThreadPoolExecutorDemo/src/common/ThreadPoolConstants.java +++ /dev/null @@ -1,11 +0,0 @@ -package common; - -public class ThreadPoolConstants { - public static final int CORE_POOL_SIZE = 5; - public static final int MAX_POOL_SIZE = 10; - public static final int QUEUE_CAPACITY = 100; - public static final Long KEEP_ALIVE_TIME = 1L; - private ThreadPoolConstants(){ - - } -} diff --git a/code/java/ThreadPoolExecutorDemo/src/threadPoolExecutor/MyRunnable.java b/code/java/ThreadPoolExecutorDemo/src/threadPoolExecutor/MyRunnable.java deleted file mode 100644 index 4ebf2dcb..00000000 --- a/code/java/ThreadPoolExecutorDemo/src/threadPoolExecutor/MyRunnable.java +++ /dev/null @@ -1,36 +0,0 @@ -package threadPoolExecutor; - -import java.util.Date; - -/** - * 这是一个简单的Runnable类,需要大约5秒钟来执行其任务。 - * @author shuang.kou - */ -public class MyRunnable implements Runnable { - - private String command; - - public MyRunnable(String s) { - this.command = s; - } - - @Override - public void run() { - System.out.println(Thread.currentThread().getName() + " Start. Time = " + new Date()); - processCommand(); - System.out.println(Thread.currentThread().getName() + " End. Time = " + new Date()); - } - - private void processCommand() { - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - - @Override - public String toString() { - return this.command; - } -} diff --git a/code/java/ThreadPoolExecutorDemo/src/threadPoolExecutor/ThreadPoolExecutorDemo.java b/code/java/ThreadPoolExecutorDemo/src/threadPoolExecutor/ThreadPoolExecutorDemo.java deleted file mode 100644 index 2e510cd6..00000000 --- a/code/java/ThreadPoolExecutorDemo/src/threadPoolExecutor/ThreadPoolExecutorDemo.java +++ /dev/null @@ -1,39 +0,0 @@ -package threadPoolExecutor; - -import java.util.concurrent.ArrayBlockingQueue; -import java.util.concurrent.ThreadPoolExecutor; -import java.util.concurrent.TimeUnit; - -import static common.ThreadPoolConstants.CORE_POOL_SIZE; -import static common.ThreadPoolConstants.KEEP_ALIVE_TIME; -import static common.ThreadPoolConstants.MAX_POOL_SIZE; -import static common.ThreadPoolConstants.QUEUE_CAPACITY; - - -public class ThreadPoolExecutorDemo { - - public static void main(String[] args) { - - //使用阿里巴巴推荐的创建线程池的方式 - //通过ThreadPoolExecutor构造函数自定义参数创建 - ThreadPoolExecutor executor = new ThreadPoolExecutor( - CORE_POOL_SIZE, - MAX_POOL_SIZE, - KEEP_ALIVE_TIME, - TimeUnit.SECONDS, - new ArrayBlockingQueue<>(QUEUE_CAPACITY), - new ThreadPoolExecutor.CallerRunsPolicy()); - - for (int i = 0; i < 10; i++) { - //创建WorkerThread对象(WorkerThread类实现了Runnable 接口) - Runnable worker = new MyRunnable("" + i); - //执行Runnable - executor.execute(worker); - } - //终止线程池 - executor.shutdown(); - while (!executor.isTerminated()) { - } - System.out.println("Finished all threads"); - } -}