summaryrefslogtreecommitdiffstats
path: root/luni/src/main/java/java/util/concurrent/locks/LockSupport.java
diff options
context:
space:
mode:
Diffstat (limited to 'luni/src/main/java/java/util/concurrent/locks/LockSupport.java')
-rw-r--r--luni/src/main/java/java/util/concurrent/locks/LockSupport.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/luni/src/main/java/java/util/concurrent/locks/LockSupport.java b/luni/src/main/java/java/util/concurrent/locks/LockSupport.java
index 0c0f07d..422e428 100644
--- a/luni/src/main/java/java/util/concurrent/locks/LockSupport.java
+++ b/luni/src/main/java/java/util/concurrent/locks/LockSupport.java
@@ -1,11 +1,10 @@
/*
* Written by Doug Lea with assistance from members of JCP JSR-166
* Expert Group and released to the public domain, as explained at
- * http://creativecommons.org/licenses/publicdomain
+ * http://creativecommons.org/publicdomain/zero/1.0/
*/
package java.util.concurrent.locks;
-import java.util.concurrent.*;
import sun.misc.Unsafe;
@@ -49,7 +48,10 @@ import sun.misc.Unsafe;
* higher-level synchronization utilities, and are not in themselves
* useful for most concurrency control applications. The {@code park}
* method is designed for use only in constructions of the form:
- * <pre>while (!canProceed()) { ... LockSupport.park(this); }</pre>
+ *
+ * <pre> {@code
+ * while (!canProceed()) { ... LockSupport.park(this); }}</pre>
+ *
* where neither {@code canProceed} nor any other actions prior to the
* call to {@code park} entail locking or blocking. Because only one
* permit is associated with each thread, any intermediary uses of
@@ -57,7 +59,7 @@ import sun.misc.Unsafe;
*
* <p><b>Sample Usage.</b> Here is a sketch of a first-in-first-out
* non-reentrant lock class:
- * <pre>{@code
+ * <pre> {@code
* class FIFOMutex {
* private final AtomicBoolean locked = new AtomicBoolean(false);
* private final Queue<Thread> waiters
@@ -92,7 +94,7 @@ public class LockSupport {
private LockSupport() {} // Cannot be instantiated.
// Hotspot implementation via intrinsics API
- private static final Unsafe unsafe = UnsafeAccess.THE_ONE; // android-changed
+ private static final Unsafe unsafe = Unsafe.getUnsafe();
private static final long parkBlockerOffset;
static {
@@ -246,10 +248,14 @@ public class LockSupport {
* snapshot -- the thread may have since unblocked or blocked on a
* different blocker object.
*
+ * @param t the thread
* @return the blocker
+ * @throws NullPointerException if argument is null
* @since 1.6
*/
public static Object getBlocker(Thread t) {
+ if (t == null)
+ throw new NullPointerException();
return unsafe.getObjectVolatile(t, parkBlockerOffset);
}