src/share/classes/java/util/concurrent/Phaser.java

Print this page




1125         }
1126 
1127         public boolean block() {
1128             if (isReleasable())
1129                 return true;
1130             else if (!timed)
1131                 LockSupport.park(this);
1132             else if (nanos > 0)
1133                 LockSupport.parkNanos(this, nanos);
1134             return isReleasable();
1135         }
1136     }
1137 
1138     // Unsafe mechanics
1139 
1140     private static final sun.misc.Unsafe UNSAFE;
1141     private static final long stateOffset;
1142     static {
1143         try {
1144             UNSAFE = sun.misc.Unsafe.getUnsafe();
1145             Class k = Phaser.class;
1146             stateOffset = UNSAFE.objectFieldOffset
1147                 (k.getDeclaredField("state"));
1148         } catch (Exception e) {
1149             throw new Error(e);
1150         }
1151     }
1152 }


1125         }
1126 
1127         public boolean block() {
1128             if (isReleasable())
1129                 return true;
1130             else if (!timed)
1131                 LockSupport.park(this);
1132             else if (nanos > 0)
1133                 LockSupport.parkNanos(this, nanos);
1134             return isReleasable();
1135         }
1136     }
1137 
1138     // Unsafe mechanics
1139 
1140     private static final sun.misc.Unsafe UNSAFE;
1141     private static final long stateOffset;
1142     static {
1143         try {
1144             UNSAFE = sun.misc.Unsafe.getUnsafe();
1145             Class<?> k = Phaser.class;
1146             stateOffset = UNSAFE.objectFieldOffset
1147                 (k.getDeclaredField("state"));
1148         } catch (Exception e) {
1149             throw new Error(e);
1150         }
1151     }
1152 }