123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- /**
- *
- * Copyright (c) behosoft Co.,Ltd.
- * All Rights Reserved.
- *
- * This software is the confidential and proprietary information of behosoft.
- * (Social Security Department). You shall not disclose such
- * Confidential Information and shall use it only in accordance with
- * the terms of the license agreement you entered into with behosoft.
- *
- * Distributable under GNU LGPL license by gnu.org
- */
- package com.behosoft.util;
- import java.util.concurrent.BlockingQueue;
- import java.util.concurrent.LinkedBlockingQueue;
- import java.util.concurrent.ThreadPoolExecutor;
- import java.util.concurrent.TimeUnit;
- /**
- *
- * <p>
- * Title: 百弘电商物流标准版_[]_[模块名]
- * </p>
- * <p>
- * Description: [描述该类概要功能介绍]
- * </p>
- * @author jiangyonghua
- * @version 1.0 2013-9-23
- * @author (lastest modification by )
- * @since 1.0
- */
- public class SimpleThreadPool extends ThreadPoolExecutor {
- public SimpleThreadPool() {
- this(4, 8, new LinkedBlockingQueue<Runnable>());
- }
- public SimpleThreadPool(int corePoolSize) {
- this(corePoolSize, corePoolSize, new LinkedBlockingQueue<Runnable>());
- }
- public SimpleThreadPool(int corePoolSize, int maximumPoolSize) {
- this(corePoolSize, maximumPoolSize, new LinkedBlockingQueue<Runnable>());
- }
- public SimpleThreadPool(int corePoolSize, int maximumPoolSize,
- BlockingQueue blockingQueue) {
- super(corePoolSize, maximumPoolSize, 5, TimeUnit.SECONDS, blockingQueue);
- }
- @Override
- public synchronized void execute(Runnable task) {
- // 如果此任务已经在队列中,立即返回
- if (this.getQueue().contains(task))
- return;
- super.execute(task);
- }
- }
|