rafadelnero / startrek-javachallengers

Oracle Code One 2019 - Star Trek Java Challengers presentation
15 stars 5 forks source link

Virtual Threads incorrect answer DEVOX 2022 Belgium. #4

Open MannyLama opened 1 year ago

MannyLama commented 1 year ago

During the presentation at Devoxx 2022 Belgium, there was a question about Virtual Threads whereas the answer would be

---------
spock
worf
---------

After some tests I did, this is actually not correct. The answer can also be

---------
worf
spock
---------

Because you can never guarantee in which order a thread will be executed in Java.

This can be tested by writing a simple test and execute this for N times until failure.

igfasouza commented 1 year ago

Hi Manny Lama,

Thanks for the feedback.

Yes, you are right. Next time we can improve/explore more this question.

Thanks for your time and happy code/studying.