1. /*
  2. * @(#)Lock.java 1.30 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 mutex, unbound to any instance or class.
  10. // KGH April 95
  11. final public class Lock {
  12. public synchronized void lock()
  13. {
  14. while (busy) {
  15. try {
  16. wait();
  17. } catch (java.lang.InterruptedException ex) {
  18. // Eat it.
  19. }
  20. }
  21. busy = true;
  22. }
  23. public synchronized void unlock()
  24. {
  25. if (!busy) {
  26. throw new Error("freeing non-busy lock");
  27. }
  28. busy = false;
  29. notifyAll();
  30. }
  31. boolean busy = false;
  32. }