Skip to content

Commit c248cae

Browse files
fix: change Wallet.lock to ReentrantReadWriteLock
1 parent b2643e4 commit c248cae

3 files changed

Lines changed: 198 additions & 190 deletions

File tree

core/src/main/java/org/bitcoinj/utils/Threading.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import java.lang.management.ThreadMXBean;
3232
import java.util.concurrent.*;
3333
import java.util.concurrent.locks.ReentrantLock;
34+
import java.util.concurrent.locks.ReentrantReadWriteLock;
3435

3536
/**
3637
* Various threading related utilities. Provides a wrapper around explicit lock creation that lets you control whether
@@ -192,6 +193,13 @@ public static CycleDetectingLockFactory.Policy getPolicy() {
192193
return policy;
193194
}
194195

196+
public static ReentrantReadWriteLock readWriteLock(String name) {
197+
if (Utils.isAndroidRuntime() && useDefaultAndroidPolicy)
198+
return new ReentrantReadWriteLock(true);
199+
else
200+
return factory.newReentrantReadWriteLock(name);
201+
}
202+
195203
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
196204
//
197205
// Generic worker pool.

0 commit comments

Comments
 (0)