I am writing a two for loops inside the fork join. since whatever the statements inside fork starts at same time and execute parallelly,
if i execute the below code
you are right they got executed in parallel.
But what is important to understand that both variables a & b changed their values from 0-9 in zero time.
So its just that simulator has to choose whose $display to flush first.
If you want to see the parallel execution.
You must see the change w.r.t. time.
Just small modification in your code :
This has nothing to do with $display output flushing,
When you have processes executing in parallel, there is no deterministic ordering between statements executing at the same time. The output you were expecting and what you actually got are both valid possibilities. Another simulator might have picked the second for-loop to execute first. However, most single single core simulators stay on one process and only switch when there is a blocking event, or the process terminates.