ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/server/Queue/Consumer.java
(Generate patch)

Comparing experimental/server/Queue/Consumer.java (file contents):
Revision 1.1 by tdb, Thu Dec 28 01:02:07 2000 UTC vs.
Revision 1.2 by tdb, Thu Dec 28 03:51:03 2000 UTC

# Line 1 | Line 1
1   class Consumer extends Thread {
2      
3 <    public Consumer(Queue queue) {
3 >    public Consumer(Queue queue, long sleepTime) {
4          _queue = queue;
5 +        _sleepTime = sleepTime;
6      }
7      
8      public void run() {
9 <        while(true) {
10 <            try { Thread.sleep(1000); } catch(Exception e) {}
11 <            String s = (String) _queue.get();
12 <            System.out.println(s);
9 >        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 +        }
25      }
26      
27      private Queue _queue;
28 +    private int _n;
29 +    private long _sleepTime;
30      
31   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines