final void push(ForkJoinTask<?> task) {
ForkJoinTask<?>[] a; ForkJoinPool p;
int b = base, s = top, n;
if ((a = array) != null) { // ignore if queue removed
int m = a.length - 1; // fenced write for task visibility
U.putOrderedObject(a, ((m & s) << ASHIFT) + ABASE, task);
U.putOrderedInt(this, QTOP, s + 1);
if ((n = s - b) <= 1) {
if ((p = pool) != null)
p.signalWork(p.workQueues, this);
}
else if (n >= m)
growArray();
}
}
U.putOrderedObject and U.putOrderedInt set the array and top of WorkQueue. So why don't just use array[i]=task and top=s+1.Iām reading the source of ForkJoinPool and meet this problem.
the source from oracle jdk 1.8(1.8.0_131).