Guest User

Untitled

a guest
Apr 24th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1.  
  2. import java.io.Serializable;
  3.  
  4. public class Management implements Serializable{
  5.     private int clients;
  6.     private int messages;
  7.    
  8.     public Management(){
  9.         this.clients=0;
  10.         this.messages=0;
  11.        
  12.     }
  13.    
  14.     synchronized public int getMessagesCount(){
  15.        
  16.         return messages;
  17.        
  18.     }
  19.    
  20.     synchronized public int getClientsCount(){
  21.         return clients;
  22.     }
  23.    
  24.     synchronized public void increaseMessagesCount(){
  25.         this.messages++;
  26.         notifyAll();
  27.     }
  28.    
  29.     synchronized public void increaseClientsCount(){
  30.        
  31.         this.clients++;
  32.         System.out.println(clients);
  33.         notifyAll();
  34.     }
  35.    
  36.     synchronized public void decreaseClientsCount(){
  37.        
  38.         this.clients--;
  39.         System.out.println(clients);
  40.         notifyAll();
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment