Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
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
YZG
yzg-util
Commits
72a368a2
Commit
72a368a2
authored
Sep 20, 2022
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
升级新版本
parent
d4ae3360
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
9 deletions
+6
-9
YzgTimeout.java
...src/main/java/com/yanzuoguang/util/helper/YzgTimeout.java
+6
-9
No files found.
yzg-util-base/src/main/java/com/yanzuoguang/util/helper/YzgTimeout.java
View file @
72a368a2
...
@@ -4,7 +4,7 @@ import com.yanzuoguang.util.log.Log;
...
@@ -4,7 +4,7 @@ import com.yanzuoguang.util.log.Log;
import
com.yanzuoguang.util.thread.ThreadHelper
;
import
com.yanzuoguang.util.thread.ThreadHelper
;
import
java.util.Queue
;
import
java.util.Queue
;
import
java.util.concurrent.
*
;
import
java.util.concurrent.
ConcurrentLinkedQueue
;
import
java.util.function.Consumer
;
import
java.util.function.Consumer
;
/**
/**
...
@@ -16,8 +16,7 @@ public class YzgTimeout {
...
@@ -16,8 +16,7 @@ public class YzgTimeout {
public
static
final
int
TIME_OUT_DEFAULT
=
15
*
1000
;
public
static
final
int
TIME_OUT_DEFAULT
=
15
*
1000
;
public
static
final
int
TIME_OUT_TIP
=
10
*
1000
;
public
static
final
int
TIME_OUT_TIP
=
10
*
1000
;
private
static
ExecutorService
executorService
;
private
static
Queue
<
TimeInfo
>
queueInfos
=
null
;
private
static
final
Queue
<
TimeInfo
>
queueInfos
=
new
ConcurrentLinkedQueue
<>();
/**
/**
...
@@ -85,18 +84,16 @@ public class YzgTimeout {
...
@@ -85,18 +84,16 @@ public class YzgTimeout {
}
}
private
static
void
init
()
{
private
static
void
init
()
{
if
(
executorService
!=
null
)
{
if
(
queueInfos
!=
null
)
{
return
;
return
;
}
}
synchronized
(
YzgTimeout
.
class
)
{
synchronized
(
YzgTimeout
.
class
)
{
if
(
executorService
!=
null
)
{
if
(
queueInfos
!=
null
)
{
return
;
return
;
}
}
executorService
=
new
ThreadPoolExecutor
(
1
,
10
,
1000
,
queueInfos
=
new
ConcurrentLinkedQueue
<>();
TimeUnit
.
MILLISECONDS
,
new
ArrayBlockingQueue
<>(
10
));
ThreadHelper
.
runThread
(()
->
{
ThreadHelper
.
runThread
(()
->
{
while
(
true
)
{
while
(
true
)
{
try
{
try
{
...
@@ -128,7 +125,7 @@ public class YzgTimeout {
...
@@ -128,7 +125,7 @@ public class YzgTimeout {
if
(
time
>
poll
.
getTimeMax
())
{
if
(
time
>
poll
.
getTimeMax
())
{
try
{
try
{
poll
.
setTimeMax
(
poll
.
getTimeMax
()
+
poll
.
getTimeOutTip
());
poll
.
setTimeMax
(
poll
.
getTimeMax
()
+
poll
.
getTimeOutTip
());
executorService
.
execute
(()
->
poll
.
getHeart
().
heart
(
time
));
ThreadHelper
.
runThread
(()
->
poll
.
getHeart
().
heart
(
time
));
}
catch
(
Exception
ex
)
{
}
catch
(
Exception
ex
)
{
ex
.
printStackTrace
();
ex
.
printStackTrace
();
}
}
...
...
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