How expensive is in_thread / how many of short ones can I spawn safely?

Hi folks!

I’ve been playing with saws with sliding cutoff recently with the goal of using pretty short ones for melodies. While looking for ways to achieve that I’ve stumbled into in_thread and arrived at the code below.

The basic idea is that I would just call the spl2 function a lot and the question is whether it is an ok way to use in_thread or is there something that is better for the task of playing multiple overlapping sounds and controling them independently?

And in any case, how expensive are the threads spawned by in_thread and how many of them can I afford creating without strangling Sonic Pi / the machine?

If this happens to be a basic question answered elsewhere, I’d appreciate being pushed in that direction!

Edit 1: I guess I have found an alternative - to launch all notes/chords on the same thread but use at to control them with the required delay - added a snippet below. Now the questions is, which of these two approaches is better (if any of them is good enough in the first place)?

def spl2(chrd, options = {})
  degrade = options[:degrade] || 0.125
  in_thread do
    with_synth :saw do
      clpf = play_chord chrd,
        env_curve: 6,
        attack: 0.005,
        attack_level: 1,
        decay: options[:decay] || 0.5,
        cutoff_slide: degrade,
        sustain_level: 0.5,
        release: options[:release] || 0.5
      control clpf, cutoff: 100
      sleep degrade
      control clpf, cutoff: 75
      sleep degrade
      control clpf, cutoff: 50

10.times do
  spl2(choose([[:a5], [:e5], [:c5], [:rest]]))
  sleep 0.25
# alternative to sleep-control-sleep-control, that won't require (explicit?) in_thread
at [degrade,degrade+degrade], [75,55] do |level|
        control clpf, cutoff: level