Skip to content

Commit dfb262d

Browse files
committed
Constrain the type the scheduler can take
1 parent 6d20ff9 commit dfb262d

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

simple/simple-common/src/main/java/org/simpleframework/common/thread/ConcurrentScheduler.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ public class ConcurrentScheduler implements Scheduler {
3535
*/
3636
private final SchedulerQueue queue;
3737

38+
/**
39+
* Constructor for the <code>ConcurrentScheduler</code> object.
40+
* This will create a scheduler with a fixed number of threads to
41+
* use before execution. Depending on the types of task that are
42+
* to be executed this should be increased for accuracy.
43+
*
44+
* @param type this is the type of the worker threads
45+
*/
46+
public ConcurrentScheduler(Class<? extends Runnable> type) {
47+
this(type, 10);
48+
}
49+
3850
/**
3951
* Constructor for the <code>ConcurrentScheduler</code> object.
4052
* This will create a scheduler with a fixed number of threads to
@@ -44,7 +56,7 @@ public class ConcurrentScheduler implements Scheduler {
4456
* @param type this is the type of the worker threads
4557
* @param size this is the number of threads for the scheduler
4658
*/
47-
public ConcurrentScheduler(Class type, int size) {
59+
public ConcurrentScheduler(Class<? extends Runnable> type, int size) {
4860
this.queue = new SchedulerQueue(type, size);
4961
}
5062

simple/simple-common/src/main/java/org/simpleframework/common/thread/SchedulerQueue.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class SchedulerQueue {
5353
* @param type this is the type of task to execute
5454
* @param size this is the number of threads for the scheduler
5555
*/
56-
public SchedulerQueue(Class type, int size) {
56+
public SchedulerQueue(Class<? extends Runnable> type, int size) {
5757
this.factory = new DaemonFactory(type);
5858
this.executor = new ScheduledThreadPoolExecutor(size, factory);
5959
}

0 commit comments

Comments
 (0)