01: // ***************************************************************
02: // * *
03: // * File: LockWithMemory.java *
04: // * *
05: // * Copyright (c) 2001 Sun Microsystems, Inc. *
06: // * All rights reserved. *
07: // * *
08: // * *
09: // * Date - Dec/11/2001 *
10: // * Author - alejandro.abdelnur@sun.com *
11: // * *
12: // ***************************************************************
13:
14: package com.sun.portal.common.concurrent;
15:
16: public class LockWithMemory {
17: private boolean signalled = false;
18:
19: public synchronized void waitFor() {
20: waitFor(0, 0);
21: }
22:
23: public synchronized void waitFor(long timeout) {
24: waitFor(timeout, 0);
25: }
26:
27: public synchronized void waitFor(long timeout, int nanos) {
28: if (!signalled) {
29: try {
30: wait(timeout, nanos);
31: } catch (Exception ex) {
32: System.out.println("waitFor(), ex: " + ex);
33: }
34: }
35: signalled = false;
36: }
37:
38: public synchronized void signal() {
39: notify();
40: signalled = true;
41: }
42:
43: }
|