You probably want a sleep in your loop. sleep(0) or sleep(1) should work. You can't pass ref objects between threads but you can ptr objects but you need to make sure all threads are done with it before freeing manually.
Channels might be a better choice. I think they copy your ref objects between threads so it should be ok.
