In reply to Abi aadhira:
I dont see any problem with the code.
Inside the repeat loop the threads are started sequentially. So thread1 will finish before thread2 starts and thread2 finishes before the thread1 of the next iteration starts.
Hope this helps.
This may be a more interesting exercsise because the threads are started in parallel
and the 8 iterations of the repeat loop will start simultaneously.
repeat(8) begin
fork
thread1();
thread2();
join_any
end
Logie Ramachandran.