sketchucation logo sketchucation
    • Login
    1. Home
    2. bcbas
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
    B
    Offline
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Groups 1

    bcbas

    @bcbas

    0
    Reputation
    1
    Profile views
    1
    Posts
    0
    Followers
    0
    Following
    Joined
    Last Online

    bcbas Unfollow Follow
    registered-users

    Latest posts made by bcbas

    • Multi-threading inside SketchUp

      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?

      posted in Developers' Forum
      B
      bcbas