1
package org.jboss.remoting.samples.chat.utility;
6
* <p>Copyright: Copyright (c) 2003</p>
8
* @author not attributable
12
import java.io.Serializable;
14
import org.jboss.remoting.samples.chat.exceptions.ShuttingDownException;
16
public class ShutDownGate implements Serializable {
18
private static final long serialVersionUID = 2;
20
private int numberOfUsers;
21
private boolean shuttingDown;
34
public synchronized void check() throws ShuttingDownException
36
if (shuttingDown == true)
37
throw new ShuttingDownException();
40
public synchronized boolean isShuttingDown()
45
public synchronized void enter() throws ShuttingDownException
47
if (shuttingDown == true)
48
throw new ShuttingDownException();
52
public synchronized void leave()
54
if (numberOfUsers <= 0)
55
throw new Error("ShutDownGate: number of Users <= 0");
57
if (--numberOfUsers == 0)
61
public synchronized void shutDown()
65
while (numberOfUsers > 0) {
67
System.out.println("shutdown(): numberOfUsers == " + numberOfUsers);
70
catch (InterruptedException ie) {}
b'\\ No newline at end of file'