Salutations Sonic Wizards and wicked smart cool folks
Apologies if this is already explained ad nauseum, taking it all back to basics, trying to grasp what’s going.
- I’m using the log panel and the order of output there (and thread name / time log info) to try and understand what’s happening
- If I add code to a workspace buffer and run with no threads or loops*, the code outputs as expected
*added a do loop that could repeatedly perform a task that might affect the virtual time (post processing)
puts 1,2,3
puts '4 5 6'
1000.times do
#sleep
#sync
#
end
puts "virtual time #{vt}"
- If I add even just one named thread, order of output can vary between runs!
(running and stopping and inspecting output)
puts 1,2,3
puts '4 5 6'
1000.times do
#sleep
#sync
#
end
puts "virtual time #{vt}"
in_thread(name: :t1) do
puts 't1 '
end
- Is this expected behaviour?
- (If expected) Can this be explained?
- Is it possible to override , eg force ordering logic?
running version v4.4
I’ve read a lot about lots, but want to keep it simple, so a 10 year old and I can comprehend!
TlDr: How to synchronise loops (in threads) and multiple named threads to start together (eg at time 0), and control/predict the order in which they will be executed and results output ?
Many thanks