How many instances are running?
APL (Dyalog Unicode), 39 bytesSBCS



Anonymous prefix function. Call by spawning on the dummy argument ⍬ (empty numeric vector), i.e. f&amp;⍬. Query currently running threads with ⎕TNUMS and kill one or more threads with ⎕TKILL n. Threads output changes in [own number, total number] as soon as they get processor time, i.e. pretty much instantly.

{⍵≡n←n[⍋n←⎕TNUMS~0]:∇n⋄∇n⊣⎕←n⍳⎕TID,⊢/n}


Try it online!

{…} anonymous lambda where ⍵ is the argument (initially ⍬, the empty numeric vector)

 n[…] index n (to be defined) with:

  ⎕TNUMS~0 all Thread Numbers except number 0 (the REPL)

   n← store as n

   ⍋ permutation which would sort ascending

  now we have the active threads in order

  ⍵≡ if the argument is identical to that…

  : then:

   ∇⍵ tail recurse on the argument

  ⋄ else:

   ⊢/n the rightmost thread number

   ⎕TID, this Thread's ID (thread number) prepended to that

   n⍳ find the ɩndices of those two

   ⎕← print that to STDOUT

   n⊣ discard that in favour of n

   ∇ recurse on that