Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package org.jboss.remoting.samples.chat.utility;

Title: Chat4

Description:

Copyright: Copyright (c) 2003

Company:

Author(s):
not attributable
Version:
1.0
public class ShutDownGate implements Serializable {
    private static final long serialVersionUID = 2;
    private int numberOfUsers;
    private boolean shuttingDown;
    public ShutDownGate()
    {
      reset();
    }
    public void reset()
    {
       = 0;
       = false;
    }
    public synchronized void check() throws ShuttingDownException
    {
      if ( == true)
        throw new ShuttingDownException();
    }
    public synchronized boolean isShuttingDown()
    {
      return ;
    }
    public synchronized void enter() throws ShuttingDownException
    {
      if ( == true)
        throw new ShuttingDownException();
      ++;
    }
    public synchronized void leave()
    {
      if ( <= 0)
        throw new Error("ShutDownGate: number of Users <= 0");
      if (-- == 0)
        notifyAll();
    }
    public synchronized void shutDown()
    {
       = true;
      while ( > 0) {
        try {
          ..println("shutdown(): numberOfUsers == " + );
          wait();
        }
        catch (InterruptedException ie) {}
      }
    }
  }
New to GrepCode? Check out our FAQ X