This is the way to go I think but you need to wait and notify on the queue as well as have synchronized blocks. Be sure that your queue is thread safe (Vector or some synchronized Set,Map). Don't use thread priority this is not well specified for the JVM. You don't have any control over how the thread priority will work.
/** Thread that sends all message to the clients */ public void run() { if(queue.size() == 0) { synchronized(queue){ try{ queue.wait(); } catch(InterruptedException ie){} } } message = queue.dequeue(); proccessMessage(message); } public void sendToClients(Message message) { queue.enqueue(message); synchronized(queue){ queue.notifyAll(); } } -Per -----Original Message----- From: Brad Christiansen [mailto:[EMAIL PROTECTED]] Sent: Monday, May 06, 2002 3:56 AM To: [EMAIL PROTECTED] Subject: Re: [JAVA3D] Multi User Server Hi, I am not sure I understand your issue completely, but for the following issue: >Another thread handles sending these queued messages to players within range of a >message origination, in >a FIFO order. That >particular thread I'm having some problems with. I need it to run all the time, or >"wake up" whenver the >message queue isn't >empty. If the queue _is_ empty, I want it to sleep quietly. I've played around with >thread priority, >and that seems to make no >difference. I can't seem to get it to either: Have you tried something along these lines ? /** Thread that sends all message to the clients */ public void run() { if(queue.size() == 0) { wait(); } message = queue.dequeue(); proccessMessage(message); } /** method used to add items to the queue */ public void sendToClients(Message message) { queue.enqueue(message); notifyAll(); } Cheers, Brad ---------------------------------------------------------------------------- This Email may contain confidential and/or privileged information and is intended solely for the addressee(s) named. If you have received this information in error, or are advised that you have been posted this Email by accident, please notify the sender by return Email, do not redistribute it, delete the Email and keep no copies. ---------------------------------------------------------------------------- =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help". ==========================================================================To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".