1248 |
|
/* |
1249 |
|
* Acquires the plock lock to protect worker array and related |
1250 |
|
* updates. This method is called only if an initial CAS on plock |
1251 |
< |
* fails. This acts as a spinLock for normal cases, but falls back |
1251 |
> |
* fails. This acts as a spinlock for normal cases, but falls back |
1252 |
|
* to builtin monitor to block when (rarely) needed. This would be |
1253 |
|
* a terrible idea for a highly contended lock, but works fine as |
1254 |
|
* a more conservative alternative to a pure spinlock. |
2559 |
|
* exit. |
2560 |
|
* |
2561 |
|
* @return the common pool instance |
2562 |
+ |
* @since 1.8 |
2563 |
|
*/ |
2564 |
|
public static ForkJoinPool commonPool() { |
2565 |
|
// assert common != null : "static init error"; |
2742 |
|
* Returns the targeted parallelism level of the common pool. |
2743 |
|
* |
2744 |
|
* @return the targeted parallelism level of the common pool |
2745 |
+ |
* @since 1.8 |
2746 |
|
*/ |
2747 |
|
public static int getCommonPoolParallelism() { |
2748 |
|
return commonParallelism; |
3410 |
|
private static sun.misc.Unsafe getUnsafe() { |
3411 |
|
try { |
3412 |
|
return sun.misc.Unsafe.getUnsafe(); |
3413 |
< |
} catch (SecurityException se) { |
3414 |
< |
try { |
3415 |
< |
return java.security.AccessController.doPrivileged |
3416 |
< |
(new java.security |
3417 |
< |
.PrivilegedExceptionAction<sun.misc.Unsafe>() { |
3418 |
< |
public sun.misc.Unsafe run() throws Exception { |
3419 |
< |
java.lang.reflect.Field f = sun.misc |
3420 |
< |
.Unsafe.class.getDeclaredField("theUnsafe"); |
3421 |
< |
f.setAccessible(true); |
3422 |
< |
return (sun.misc.Unsafe) f.get(null); |
3423 |
< |
}}); |
3424 |
< |
} catch (java.security.PrivilegedActionException e) { |
3425 |
< |
throw new RuntimeException("Could not initialize intrinsics", |
3426 |
< |
e.getCause()); |
3427 |
< |
} |
3413 |
> |
} catch (SecurityException tryReflectionInstead) {} |
3414 |
> |
try { |
3415 |
> |
return java.security.AccessController.doPrivileged |
3416 |
> |
(new java.security.PrivilegedExceptionAction<sun.misc.Unsafe>() { |
3417 |
> |
public sun.misc.Unsafe run() throws Exception { |
3418 |
> |
Class<sun.misc.Unsafe> k = sun.misc.Unsafe.class; |
3419 |
> |
for (java.lang.reflect.Field f : k.getDeclaredFields()) { |
3420 |
> |
f.setAccessible(true); |
3421 |
> |
Object x = f.get(null); |
3422 |
> |
if (k.isInstance(x)) |
3423 |
> |
return k.cast(x); |
3424 |
> |
} |
3425 |
> |
throw new NoSuchFieldError("the Unsafe"); |
3426 |
> |
}}); |
3427 |
> |
} catch (java.security.PrivilegedActionException e) { |
3428 |
> |
throw new RuntimeException("Could not initialize intrinsics", |
3429 |
> |
e.getCause()); |
3430 |
|
} |
3431 |
|
} |
3428 |
– |
|
3432 |
|
} |