| | |
| | | wait(); |
| | | } catch (InterruptedException e) |
| | | { |
| | | throw(IOException) new IOException().initCause(e); |
| | | throw (IOException) new IOException().initCause(e); |
| | | } |
| | | } |
| | | } |
| | |
| | | assertTrue("A write lock exists that is owned by another thread", canRead()); |
| | | |
| | | Thread current = Thread.currentThread(); |
| | | Owner owner = (Owner) owners.get(current); |
| | | Owner owner = (Owner) owners.get(current); |
| | | |
| | | if (owner != null) |
| | | { |
| | |
| | | wait(); |
| | | } catch (InterruptedException e) |
| | | { |
| | | throw(IOException) new IOException().initCause(e); |
| | | throw (IOException) new IOException().initCause(e); |
| | | } |
| | | |
| | | if (writer == null) |
| | |
| | | private class Owner |
| | | { |
| | | final Thread owner; |
| | | int timesLocked; |
| | | int timesLocked; |
| | | |
| | | Owner(Thread owner) |
| | | { |
| | | this.owner = owner; |
| | | this.owner = owner; |
| | | timesLocked = 1; |
| | | } |
| | | |