Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Coudy Hou
JavaGuide
提交
ef58b8d0
J
JavaGuide
项目概览
Coudy Hou
/
JavaGuide
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
JavaGuide
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ef58b8d0
编写于
11月 12, 2019
作者:
K
Kou Shuang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
java线程池学习总结
上级
f195dded
变更
13
展开全部
隐藏空白更改
内联
并排
Showing
13 changed file
with
156 addition
and
0 deletion
+156
-0
README.md
README.md
+1
-0
code/java/ThreadPoolExecutorDemo/.idea/.gitignore
code/java/ThreadPoolExecutorDemo/.idea/.gitignore
+2
-0
code/java/ThreadPoolExecutorDemo/.idea/checkstyle-idea.xml
code/java/ThreadPoolExecutorDemo/.idea/checkstyle-idea.xml
+16
-0
code/java/ThreadPoolExecutorDemo/.idea/inspectionProfiles/Project_Default.xml
...ExecutorDemo/.idea/inspectionProfiles/Project_Default.xml
+36
-0
code/java/ThreadPoolExecutorDemo/.idea/misc.xml
code/java/ThreadPoolExecutorDemo/.idea/misc.xml
+6
-0
code/java/ThreadPoolExecutorDemo/.idea/modules.xml
code/java/ThreadPoolExecutorDemo/.idea/modules.xml
+8
-0
code/java/ThreadPoolExecutorDemo/.idea/vcs.xml
code/java/ThreadPoolExecutorDemo/.idea/vcs.xml
+6
-0
code/java/ThreadPoolExecutorDemo/ThreadPoolExecutorDemo.iml
code/java/ThreadPoolExecutorDemo/ThreadPoolExecutorDemo.iml
+11
-0
code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/ThreadPoolExecutorDemo.class
...ction/ThreadPoolExecutorDemo/ThreadPoolExecutorDemo.class
+0
-0
code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/WorkerThread.class
.../out/production/ThreadPoolExecutorDemo/WorkerThread.class
+0
-0
code/java/ThreadPoolExecutorDemo/src/ThreadPoolExecutorDemo.java
...va/ThreadPoolExecutorDemo/src/ThreadPoolExecutorDemo.java
+36
-0
code/java/ThreadPoolExecutorDemo/src/WorkerThread.java
code/java/ThreadPoolExecutorDemo/src/WorkerThread.java
+34
-0
docs/java/Multithread/java线程池学习总结.md
docs/java/Multithread/java线程池学习总结.md
+0
-0
未找到文件。
README.md
浏览文件 @
ef58b8d0
...
...
@@ -94,6 +94,7 @@
*
**[Java 并发进阶常见面试题总结](docs/java/Multithread/JavaConcurrencyAdvancedCommonInterviewQuestions.md)**
*
[
并发容器总结
](
docs/java/Multithread/并发容器总结.md
)
*
[
乐观锁与悲观锁
](
docs/essential-content-for-interview/面试必备之乐观锁与悲观锁.md
)
*
[
Java线程池学习总结
](
./docs/java/Multithread/java线程池学习总结.md
)
*
[
JUC 中的 Atomic 原子类总结
](
docs/java/Multithread/Atomic.md
)
*
[
AQS 原理以及 AQS 同步组件总结
](
docs/java/Multithread/AQS.md
)
...
...
code/java/ThreadPoolExecutorDemo/.idea/.gitignore
0 → 100644
浏览文件 @
ef58b8d0
# Default ignored files
/workspace.xml
\ No newline at end of file
code/java/ThreadPoolExecutorDemo/.idea/checkstyle-idea.xml
0 → 100644
浏览文件 @
ef58b8d0
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"CheckStyle-IDEA"
>
<option
name=
"configuration"
>
<map>
<entry
key=
"checkstyle-version"
value=
"8.25"
/>
<entry
key=
"copy-libs"
value=
"false"
/>
<entry
key=
"location-0"
value=
"BUNDLED:(bundled):Sun Checks"
/>
<entry
key=
"location-1"
value=
"BUNDLED:(bundled):Google Checks"
/>
<entry
key=
"scan-before-checkin"
value=
"false"
/>
<entry
key=
"scanscope"
value=
"JavaOnly"
/>
<entry
key=
"suppress-errors"
value=
"false"
/>
</map>
</option>
</component>
</project>
\ No newline at end of file
code/java/ThreadPoolExecutorDemo/.idea/inspectionProfiles/Project_Default.xml
0 → 100644
浏览文件 @
ef58b8d0
<component
name=
"InspectionProjectProfileManager"
>
<profile
version=
"1.0"
>
<option
name=
"myName"
value=
"Project Default"
/>
<inspection_tool
class=
"JavaDoc"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
>
<option
name=
"TOP_LEVEL_CLASS_OPTIONS"
>
<value>
<option
name=
"ACCESS_JAVADOC_REQUIRED_FOR"
value=
"none"
/>
<option
name=
"REQUIRED_TAGS"
value=
""
/>
</value>
</option>
<option
name=
"INNER_CLASS_OPTIONS"
>
<value>
<option
name=
"ACCESS_JAVADOC_REQUIRED_FOR"
value=
"none"
/>
<option
name=
"REQUIRED_TAGS"
value=
""
/>
</value>
</option>
<option
name=
"METHOD_OPTIONS"
>
<value>
<option
name=
"ACCESS_JAVADOC_REQUIRED_FOR"
value=
"none"
/>
<option
name=
"REQUIRED_TAGS"
value=
"@return@param@throws or @exception"
/>
</value>
</option>
<option
name=
"FIELD_OPTIONS"
>
<value>
<option
name=
"ACCESS_JAVADOC_REQUIRED_FOR"
value=
"none"
/>
<option
name=
"REQUIRED_TAGS"
value=
""
/>
</value>
</option>
<option
name=
"IGNORE_DEPRECATED"
value=
"false"
/>
<option
name=
"IGNORE_JAVADOC_PERIOD"
value=
"true"
/>
<option
name=
"IGNORE_DUPLICATED_THROWS"
value=
"false"
/>
<option
name=
"IGNORE_POINT_TO_ITSELF"
value=
"false"
/>
<option
name=
"myAdditionalJavadocTags"
value=
"date"
/>
</inspection_tool>
</profile>
</component>
\ No newline at end of file
code/java/ThreadPoolExecutorDemo/.idea/misc.xml
0 → 100644
浏览文件 @
ef58b8d0
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_8"
default=
"true"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/out"
/>
</component>
</project>
\ No newline at end of file
code/java/ThreadPoolExecutorDemo/.idea/modules.xml
0 → 100644
浏览文件 @
ef58b8d0
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ProjectModuleManager"
>
<modules>
<module
fileurl=
"file://$PROJECT_DIR$/ThreadPoolExecutorDemo.iml"
filepath=
"$PROJECT_DIR$/ThreadPoolExecutorDemo.iml"
/>
</modules>
</component>
</project>
\ No newline at end of file
code/java/ThreadPoolExecutorDemo/.idea/vcs.xml
0 → 100644
浏览文件 @
ef58b8d0
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"VcsDirectoryMappings"
>
<mapping
directory=
"$PROJECT_DIR$/../../.."
vcs=
"Git"
/>
</component>
</project>
\ No newline at end of file
code/java/ThreadPoolExecutorDemo/ThreadPoolExecutorDemo.iml
0 → 100644
浏览文件 @
ef58b8d0
<?xml version="1.0" encoding="UTF-8"?>
<module
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
inherit-compiler-output=
"true"
>
<exclude-output
/>
<content
url=
"file://$MODULE_DIR$"
>
<sourceFolder
url=
"file://$MODULE_DIR$/src"
isTestSource=
"false"
/>
</content>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
</component>
</module>
\ No newline at end of file
code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/ThreadPoolExecutorDemo.class
0 → 100644
浏览文件 @
ef58b8d0
文件已添加
code/java/ThreadPoolExecutorDemo/out/production/ThreadPoolExecutorDemo/WorkerThread.class
0 → 100644
浏览文件 @
ef58b8d0
文件已添加
code/java/ThreadPoolExecutorDemo/src/ThreadPoolExecutorDemo.java
0 → 100644
浏览文件 @
ef58b8d0
import
java.util.concurrent.ArrayBlockingQueue
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
public
class
ThreadPoolExecutorDemo
{
private
static
final
int
CORE_POOL_SIZE
=
5
;
private
static
final
int
MAX_POOL_SIZE
=
10
;
private
static
final
int
QUEUE_CAPACITY
=
100
;
private
static
final
Long
KEEP_ALIVE_TIME
=
1L
;
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
WorkerThread
(
""
+
i
);
//执行Runnable
executor
.
execute
(
worker
);
}
//终止线程池
executor
.
shutdown
();
while
(!
executor
.
isTerminated
())
{
}
System
.
out
.
println
(
"Finished all threads"
);
}
}
code/java/ThreadPoolExecutorDemo/src/WorkerThread.java
0 → 100644
浏览文件 @
ef58b8d0
import
java.util.Date
;
/**
* 这是一个简单的Runnable类,需要大约5秒钟来执行其任务。
* @author shuang.kou
*/
public
class
WorkerThread
implements
Runnable
{
private
String
command
;
public
WorkerThread
(
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
;
}
}
docs/java/Multithread/java线程池学习总结.md
0 → 100644
浏览文件 @
ef58b8d0
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录