There is a happens before edge between calling the start method of a thread
and the thread running.

On JMM level that is sufficient.

On Thu, Jul 29, 2021, 18:47 r r <[email protected]> wrote:

> Hello,
>
> We have the simple pseudocode:
>
> void main(String[] args) {
>     MemoryBuffer b = new MemoryBuffer(); // it is a off-heap native piece
> of memory allocated by malloc via JNI
>     b.init(); // it just write some data to the memory buffer by JNI
>     startThreadsThatReadsFromBuffer(b); // this functions starts threads
> that read the b
>     // There is no locks / synchronization etc.
> }
>
> It seems to be thread-safe in the sense of Java Memory Model. But, I
> cannot convince myself why it is correct. Especially, how can I be sure
> that worker threads see completely intizalized buffer b?
>
> --
> You received this message because you are subscribed to the Google Groups
> "mechanical-sympathy" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web, visit
> https://groups.google.com/d/msgid/mechanical-sympathy/84ab88bc-e0bf-4e19-8c39-eeea619bf0f0n%40googlegroups.com
> <https://groups.google.com/d/msgid/mechanical-sympathy/84ab88bc-e0bf-4e19-8c39-eeea619bf0f0n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"mechanical-sympathy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web, visit 
https://groups.google.com/d/msgid/mechanical-sympathy/CAGuAWdB5X9G7wL7GjXaCOv3OCTY%3D2EE0SFV-smmHAk3gurQbXQ%40mail.gmail.com.

Reply via email to