Advertisement
crownedzero

Consumer

Nov 15th, 2012
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 KB | None | 0 0
  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package domain;
  6.  
  7. import java.util.ArrayList;
  8. import java.util.List;
  9. import java.util.logging.Level;
  10. import java.util.logging.Logger;
  11.  
  12. /**
  13.  *
  14.  * @author crownedzero
  15.  */
  16. public class Consumer implements Runnable {
  17.    
  18.     private List<Message> consumerList = new ArrayList<>();
  19.  
  20.     @Override
  21.     public void run() {
  22.         while (true) {
  23.             try {
  24.                 Message tempMessage = Producer.messageConsume(Thread.currentThread().getName());
  25.                 if (tempMessage.getRegion().equalsIgnoreCase(Thread.currentThread().getName())) {
  26.                     consumerList.add(tempMessage);
  27.                 }  Thread.sleep(500);
  28.             } catch (InterruptedException ex) {
  29.                 Logger.getLogger(Consumer.class.getName()).log(Level.SEVERE, null, ex);
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement