3 ms·
Might want to move foo.add() out of the lock scope (assuming foo is a thread-private resource): value = nil lock { if (data.size() > 0) {
by another-acct 2y ago
Might want to move foo.add() out of the lock scope (assuming foo is a thread-private resource):
value = nil
lock {
if (data.size() > 0) {
value = data.pop()
}
}
if (value) {
foo.add(value)
}