I missed addressing the Unsafe class usage. First of all, why do you think they call it Unsafe? If you’re not familiar with the Class, then go look at it.
The Unsafe class is primarily for profilers and debuggers. They need direct access to memory. The concurrency utilities use Unsafe to get around the limits of wait()/notify() using park() and unpark(). There may also be an issue with the atomic instructions on CPUs. Most processors support atomic operation like FetchAndAdd and CompareAndSwap, but not in the same way. Some use LL/SC instead of CAS. So there is surely a need today for using Unsafe for atomic operations. API’s do things normal application programs don’t so it is what it is. The F/J framework is not an API. It is an application program. That is the major difference. There is absolutely no need to program in pseudo-C to do fork-join. Here is a quote from the ForkJoinWorkerThread: “Efficient implementation of these algorithms currently relies on an uncomfortable amount of "Unsafe" mechanics.” Even the author knows he’s overdone it. He doesn’t use a standard deque from the concurrency utilities, he hard codes direct memory access to emulate a deque. The code in all his classes have massive amounts of Unsafe use. Why? Is it to get around the slow, clumsy work-stealing algorithm? I don’t see a need for it. It adds a huge amount of complexity. I can say from decades of experience, complexity always fails, always. I developed four fork-join frameworks that run on Java SE, ME, and Android without any Unsafe usage. They’re faster than the F/J framework and have professional attributes. Unsafe has no place in application programming. -- You received this message because you are subscribed to the Google Groups "The Java Posse" group. To view this discussion on the web visit https://groups.google.com/d/msg/javaposse/-/6a9PfIokayIJ. To post to this group, send email to javaposse@googlegroups.com. To unsubscribe from this group, send email to javaposse+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/javaposse?hl=en.