Commit 65d30f1a authored by 刘文胜's avatar 刘文胜

1111

parent fc3f6d25
......@@ -29,7 +29,9 @@ import com.hdp.pi.wechat.messages.NewUserMessage;
public final class IMManager {
private static Log log=LogFactory.getLog(IMManager.class);
private static ExecutorService pool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 2);
private static int poolSize = Runtime.getRuntime().availableProcessors() * 2;
private static ExecutorService pool = Executors.newFixedThreadPool(poolSize);
private static CopyOnWriteArrayList<Waiter> waiters = new CopyOnWriteArrayList<Waiter>();
......@@ -87,17 +89,13 @@ public final class IMManager {
waiters.remove(w);
}
static{
int pross = Runtime.getRuntime().availableProcessors();
if(pross == 0 ){
pross = 1;
}
for(int i=0;i<pross;i++){
for(int i=0;i<poolSize;i++){
pool.execute(new Runnable() {//消息发射器
public void hand(){
AbstractMessage e=queue.poll();
if(e == null){
try {
Thread.sleep(50);
Thread.sleep(10);
} catch (InterruptedException e1) {
}
return ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment