1. /*
  2. * @(#)Condition.java 1.39 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package com.sun.corba.se.internal.orbutil;
  8. //
  9. // Traditional Condition variables, unbound to any instance or class.
  10. // KGH April 95
  11. final public class Condition {
  12. public Condition() {
  13. }
  14. public void wait(Lock lock) {
  15. synchronized (this) {
  16. lock.unlock();
  17. boolean ok = false;
  18. while (!ok) {
  19. try {
  20. super.wait();
  21. ok = true;
  22. } catch (InterruptedException ex) {
  23. // Eat it and loop again. The user doesn't care how
  24. // long we wait.
  25. }
  26. }
  27. }
  28. lock.lock();
  29. }
  30. public void wait(Lock lock, int timeout)
  31. throws InterruptedException {
  32. synchronized (this) {
  33. lock.unlock();
  34. super.wait(timeout);
  35. }
  36. lock.lock();
  37. }
  38. public synchronized void signal() {
  39. super.notify();
  40. }
  41. public synchronized void signalAll() {
  42. super.notifyAll();
  43. }
  44. }