dispatcher.java

来自「piweurrrrq i o fhsadhfka fd dskajc zxkjc」· Java 代码 · 共 49 行

JAVA
49
字号
/* * Copyright (c) 2000 Lyrisoft Solutions, Inc. * Used by permission */package com.lyrisoft.chat.server.remote;import java.util.Map;import java.util.LinkedList;import java.util.List;import java.util.Iterator;import java.util.Collections;public class Dispatcher implements Runnable {    protected List _queue;    protected boolean _keepGoing = true;    public Dispatcher() {        _queue = Collections.synchronizedList(new LinkedList());    }    public void queue(Message m) {        _queue.add(m);    }    public void run() {        while (_keepGoing) {            try {                flush();                Thread.sleep(5);            }            catch (InterruptedException e) {                 e.printStackTrace();            }        }    }    public void flush() {        while (_queue.size() > 0) {            Message m = (Message)_queue.remove(0);            m.send();        }    }    public void pleaseStop() {        _keepGoing = false;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?