ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/server/Queue/Consumer.java
Revision: 1.2
Committed: Thu Dec 28 03:51:03 2000 UTC (23 years, 11 months ago) by tdb
Branch: MAIN
Changes since 1.1: +19 -5 lines
Log Message:
Added a changeable sleep time, and support for the multiple-consumer
features now in the Queue.

File Contents

# User Rev Content
1 tdb 1.1 class Consumer extends Thread {
2    
3 tdb 1.2 public Consumer(Queue queue, long sleepTime) {
4 tdb 1.1 _queue = queue;
5 tdb 1.2 _sleepTime = sleepTime;
6 tdb 1.1 }
7    
8     public void run() {
9 tdb 1.2 boolean run;
10     try {
11     _n = _queue.getQueue();
12     System.out.println("Got queue: "+_n);
13     run = true;
14     }
15     catch(NoQueueException e) {
16     System.out.println("Failed to get a Queue:");
17     System.out.println(e);
18     run=false;
19     }
20     while(run) {
21     try { Thread.sleep(_sleepTime); } catch(Exception e) {}
22     String s = (String) _queue.get(_n);
23     System.out.println("["+_n+"] "+s);
24 tdb 1.1 }
25     }
26    
27     private Queue _queue;
28 tdb 1.2 private int _n;
29     private long _sleepTime;
30 tdb 1.1
31     }