Fix bug in synchronous monitor unlocking

This commit is contained in:
Alexey Andreev 2015-10-19 17:42:35 +03:00
parent 84be461a69
commit a96ee8a647

View File

@ -56,6 +56,8 @@ public class TObject {
} }
if (o.monitor.owner == null) { if (o.monitor.owner == null) {
o.monitor.owner = TThread.currentThread(); o.monitor.owner = TThread.currentThread();
} else if (o.monitor.owner != TThread.currentThread()) {
throw new IllegalStateException("Can't enter monitor from another thread synchronously");
} }
o.monitor.count++; o.monitor.count++;
} }
@ -64,7 +66,9 @@ public class TObject {
if (o.isEmptyMonitor() || o.monitor.owner != TThread.currentThread()) { if (o.isEmptyMonitor() || o.monitor.owner != TThread.currentThread()) {
throw new TIllegalMonitorStateException(); throw new TIllegalMonitorStateException();
} }
--o.monitor.count; if (--o.monitor.count == 0) {
o.monitor.owner = null;
}
o.isEmptyMonitor(); o.isEmptyMonitor();
} }