This commit is contained in:
@@ -25,8 +25,8 @@ public class WorkThread extends Thread {
|
|||||||
this.setDaemon(true);
|
this.setDaemon(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void submit(Runnable runner) {
|
public Future<?> submit(Runnable runner) {
|
||||||
executor.submit(runner);
|
return executor.submit(runner);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExecutorService getExecutor() {
|
public ExecutorService getExecutor() {
|
||||||
|
|||||||
32
src/org/redkale/service/AbstractService.java
Normal file
32
src/org/redkale/service/AbstractService.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* To change this license header, choose License Headers in Project Properties.
|
||||||
|
* To change this template file, choose Tools | Templates
|
||||||
|
* and open the template in the editor.
|
||||||
|
*/
|
||||||
|
package org.redkale.service;
|
||||||
|
|
||||||
|
import java.util.concurrent.*;
|
||||||
|
import org.redkale.net.WorkThread;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author zhangjx
|
||||||
|
*/
|
||||||
|
public abstract class AbstractService implements Service {
|
||||||
|
|
||||||
|
protected Future<?> submit(Runnable runner) {
|
||||||
|
Thread thread = Thread.currentThread();
|
||||||
|
if (thread instanceof WorkThread) {
|
||||||
|
return ((WorkThread) thread).submit(runner);
|
||||||
|
}
|
||||||
|
return ForkJoinPool.commonPool().submit(runner);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected ExecutorService getExecutor() {
|
||||||
|
Thread thread = Thread.currentThread();
|
||||||
|
if (thread instanceof WorkThread) {
|
||||||
|
return ((WorkThread) thread).getExecutor();
|
||||||
|
}
|
||||||
|
return ForkJoinPool.commonPool();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user