Javadoc of Executor interface says the following:
Memory consistency effects: Actions in a thread prior to submitting a
Runnable
object to anExecutor
happen-before its execution begins, perhaps in another thread.
Which part of the Java Language Specification guarantees that? Or is it only because the implementations use some internal synchronization? (An example would be great if that's the case.) So when implementing a custom Executor
should I be aware of this requirement?
The JLS doesn't specify the API. It specifies the language. The javadoc is the API specification.
And thus yes, if you were to implement an Executor, you'd better comply with the specifications of the Executor interface. The executor must take care that the submission happens-before the execution of the task. That doesn't happen by itself. Synchronization is needed (wait/notify, volatile write/read, etc.).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With