SL_U2_SJ
Obai Albek 2025-05-23 15:36:29 +02:00
parent 3e6281177a
commit 9982245715
2 changed files with 28 additions and 26 deletions

View File

@ -52,9 +52,8 @@ public class ThreadsafeSimplifiedList<T> implements SimplifiedList<T> {
} }
} }
try { try {
return (ptr.element); return delay(ptr.element);
} } finally {
finally {
ptr.lock.unlock(); ptr.lock.unlock();
} }
} }
@ -113,10 +112,13 @@ public class ThreadsafeSimplifiedList<T> implements SimplifiedList<T> {
throw new IndexOutOfBoundsException(index + " out of bounds"); throw new IndexOutOfBoundsException(index + " out of bounds");
} }
} }
try {
var prevElement = ptr.element; var prevElement = ptr.element;
ptr.element = element; ptr.element = element;
ptr.lock.unlock();
return prevElement; return prevElement;
} finally {
ptr.lock.unlock();
}
} }
/** /**