org.springframework.stereotype.java.util.concurrent.ArrayBlockingQueuejava.util.concurrent.Executorsjava.util.concurrent.ThreadPoolExecutorjava.util.concurrent.TimeUnitMyThreadPoolManager {
= Runtime.().availableProcessors()= + = * + = () {
}
MyThreadPoolManager MyThreadPoolManager () {
(== ) {
= MyThreadPoolManager()}
}
ThreadPoolExecutor (Runnable r) {
(== ) {
= ThreadPoolExecutor(TimeUnit.ArrayBlockingQueue<Runnable>()Executors.()ThreadPoolExecutor.AbortPolicy())}
.execute(r)}
(Runnable r) {
(r != ) {
.getQueue().remove(r)}
}
}
=================================其他类中调用==================================
@Autowired
private MyThreadPoolManager myThreadPoolManager;
/**
* 默认加载
*/
@PostConstruct
public void chuShiHua1(){
myThreadPoolManager.execute(new Runnable() {
@Override
public void run() {
//相关的业务逻辑。
}
});
} |