Has anybody else ever tried running some threads from a SketchUp Ruby script? I'm facing a strange behavior that can be easily reproduced by running the following command line in Ruby console:
Thread.new { while(true); puts "Running..."; end; }
You'll see some "Running..." messages printed to the console, but then it suddenly stops. One can argue that all subordinate threads are killed once the script finishes its execution. But then, try running the following code:
Thread.list
You'll see that the thread you've created by running the first ruby command still exists - and more interesting, SketchUp Ruby module says it's running! Again, one can argue that the thread IS REALLY running, just the console is not showing the messages anymore. But if we make our thread output to a file, we will see that the same thing happens.
Even more interesting is to make a thread run, sleep for a second and observe it sleeps forever (it will never wake up again, even when the sleep time is reached):
Thread.new { while(true); puts "Running..."; sleep(1); end; }
So, what I'm wondering is why this happens? What are the multi-threading rules and concepts inside SketchUp?