Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. $global_var_altered = false
  2. $threads{}
  3. freq = [1,2,3...]
  4.  
  5. object = Object.new
  6.  
  7. freq.each do |num|
  8. $threads[num] = Thread.new {object.function_that_changes_global_var}
  9. end
  10.  
  11. $threads.each do |thr|
  12. thr.join
  13. $threads.delete(thr[0])
  14. end
  15.  
  16. p $global_var_altered
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement