-1

while going thru this article: https://4comprehension.com/parallel-collection-processing-1/ I saw the sentence -- ForkJoinPool is not a part of the public contract -- What does this mean exactly. As per my understanding ForkJoinPool is a public class with public methods in it.so it is a part of the public contract. But the above article says that ForkJoinPool is not a part of the public contract. Please clarify

  • 2
    Immediately after that sentence in the article you linked is a quote explaining what is meant. It also contains a link to [this answer](https://stackoverflow.com/questions/28985704/parallel-stream-from-a-hashset-doesnt-run-in-parallel/29272776#29272776). – Sean Bright Feb 18 '20 at 18:44

1 Answers1

1

The word "public" which you seem to be focusing on is not really concerned with the public keyword from the Java language. In the context of the post you are referring to it means that Java streams internally depend on ForkJoin pool. However, it is an implementation detail and there is no guarantee that it will continue to be like that. In other words it is not part of the contract made between the language users (genral public like you) and language implementers.

lukeg
  • 4,189
  • 3
  • 19
  • 40
  • Also, the public contract to which they are referring is the ManagedBlocker interface (Not the ForkJoinPool class). In OOP, 'contract' is another word for interface (sort of). When you implement an interface, you are entering into a contract by promising that you will implement the required methods in your class. A link to the documentation for said interface can be found [here](https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ForkJoinPool.ManagedBlocker.html) – Nate T Feb 18 '20 at 19:45