Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
fgqyxxlr
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yaru
fgqyxxlr
Commits
975829f2
Commit
975829f2
authored
Mar 15, 2019
by
geekymv
Committed by
若依
Mar 15, 2019
Browse files
Options
Browse Files
Download
Plain Diff
!78 记录异常日志(默认情况下,线程池会捕获任务抛出的所有异常,但是不做任何处理)
Merge pull request !78 from geekymv/master
parents
9bf80906
c9dad631
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
1 deletions
+27
-1
ruoyi-common/src/main/java/com/ruoyi/common/config/thread/ThreadPoolConfig.java
+27
-1
No files found.
ruoyi-common/src/main/java/com/ruoyi/common/config/thread/ThreadPoolConfig.java
View file @
975829f2
package
com
.
ruoyi
.
common
.
config
.
thread
;
import
java.util.concurrent.CancellationException
;
import
java.util.concurrent.ExecutionException
;
import
java.util.concurrent.Future
;
import
java.util.concurrent.ScheduledExecutorService
;
import
java.util.concurrent.ScheduledThreadPoolExecutor
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
org.apache.commons.lang3.concurrent.BasicThreadFactory
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor
;
...
...
@@ -16,6 +21,8 @@ import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
@Configuration
public
class
ThreadPoolConfig
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ThreadPoolConfig
.
class
);
// 核心线程池大小
private
int
corePoolSize
=
50
;
...
...
@@ -48,6 +55,25 @@ public class ThreadPoolConfig
protected
ScheduledExecutorService
scheduledExecutorService
()
{
return
new
ScheduledThreadPoolExecutor
(
corePoolSize
,
new
BasicThreadFactory
.
Builder
().
namingPattern
(
"schedule-pool-%d"
).
daemon
(
true
).
build
());
new
BasicThreadFactory
.
Builder
().
namingPattern
(
"schedule-pool-%d"
).
daemon
(
true
).
build
())
{
@Override
protected
void
afterExecute
(
Runnable
r
,
Throwable
t
)
{
super
.
afterExecute
(
r
,
t
);
if
(
t
==
null
&&
r
instanceof
Future
<?>)
{
try
{
Object
result
=
((
Future
<?>)
r
).
get
();
}
catch
(
CancellationException
ce
)
{
t
=
ce
;
}
catch
(
ExecutionException
ee
)
{
t
=
ee
.
getCause
();
}
catch
(
InterruptedException
ie
)
{
Thread
.
currentThread
().
interrupt
();
// ignore/reset
}
}
if
(
t
!=
null
)
{
log
.
error
(
t
.
getMessage
());
}
}
};
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment