Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
65e94e69
Commit
65e94e69
authored
Jan 08, 2020
by
Junling Bu
Browse files
fix[litemall-core]: 修复潜在问题。
parent
7df32f31
Changes
2
Show whitespace changes
Inline
Side-by-side
litemall-core/src/main/java/org/linlinjava/litemall/core/task/Task.java
View file @
65e94e69
package
org.linlinjava.litemall.core.task
;
package
org.linlinjava.litemall.core.task
;
import
com.google.common.primitives.Ints
;
import
java.time.LocalDateTime
;
import
java.util.concurrent.Delayed
;
import
java.util.concurrent.Delayed
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -24,7 +27,7 @@ public abstract class Task implements Delayed, Runnable{
...
@@ -24,7 +27,7 @@ public abstract class Task implements Delayed, Runnable{
@Override
@Override
public
int
compareTo
(
Delayed
o
)
{
public
int
compareTo
(
Delayed
o
)
{
return
(
int
)(
this
.
getDelay
(
TimeUnit
.
MILLISECONDS
)
-
o
.
getDelay
(
TimeUnit
.
MILLISECONDS
)
);
return
Ints
.
saturatedCast
(
this
.
start
-
((
Task
)
o
).
start
);
}
}
@Override
@Override
...
...
litemall-core/src/test/java/org/linlinjava/litemall/core/TaskTest.java
View file @
65e94e69
...
@@ -89,4 +89,21 @@ public class TaskTest {
...
@@ -89,4 +89,21 @@ public class TaskTest {
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
@Test
public
void
test2
()
{
DateTimeFormatter
df
=
DateTimeFormatter
.
ofPattern
(
"yyyy-MM-dd HH:mm:ss"
);
String
now
=
df
.
format
(
LocalDateTime
.
now
());
System
.
out
.
println
(
"start at time="
+
now
);
taskService
.
addTask
(
new
DemoTask
(
"1"
,
0
));
taskService
.
addTask
(
new
DemoTask
(
"2"
,
1200
));
taskService
.
addTask
(
new
DemoTask
(
"3"
,
5200
));
try
{
Thread
.
sleep
(
10
*
1000
);
}
catch
(
InterruptedException
e
)
{
e
.
printStackTrace
();
}
}
}
}
Write
Preview
Supports
Markdown
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