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.2 by tdb, Thu Dec 28 03:51:03 2000 UTC vs.
Revision 1.3 by tdb, Tue Jan 2 01:54:19 2001 UTC

# Line 1 | Line 1
1   class Consumer extends Thread {
2      
3 <    public Consumer(Queue queue, long sleepTime) {
3 >    public Consumer(Queue queue, long sleepTime, int repititions) {
4          _queue = queue;
5          _sleepTime = sleepTime;
6 +        _repititions = repititions;
7      }
8      
9      public void run() {
10 <        boolean run;
11 <        try {
12 <            _n = _queue.getQueue();
13 <            System.out.println("Got queue: "+_n);
14 <            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 <        }
10 >        boolean run = true;
11 >        _n = _queue.getQueue();
12 >        System.out.println("Got queue: "+_n);
13 >        String s = null;
14 >        int i = 0;
15          while(run) {
16              try { Thread.sleep(_sleepTime); } catch(Exception e) {}
17 <            String s = (String) _queue.get(_n);
17 >            try {
18 >                s = (String) _queue.get(_n);
19 >            }
20 >            catch(InvalidQueueException e) {
21 >                System.out.println(e);
22 >                run=false;
23 >            }
24              System.out.println("["+_n+"] "+s);
25 +            i++;
26 +            if(i==_repititions) {
27 +                run = false;
28 +            }
29          }
30 +        System.out.println("Closing down, and releasing queue "+_n);
31 +        _queue.removeQueue(_n);
32      }
33      
34      private Queue _queue;
35      private int _n;
36      private long _sleepTime;
37 +    private int _repititions;
38      
39   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines