[plt-scheme] threadcount?
At 22 Sep 2006 19:29:16 -0000, Paul Graham wrote:
> Is there any way to tell in mzscheme how many threads are
> currently alive?
Depends on your definition of "alive". `vector-set-performance-stats!'
provides a count that doesn't include threads that are blocked on
channels or semaphores.
(define (number-of-alive-threads)
(let ([v (make-vector 7)])
(vector-set-performance-stats! v)
(vector-ref v 6)))
If you arrange to have a sufficiently powerful custodian (i.e., you
grab the original and install a new one before running the rest of your
program), then you can use `custodian-managed-list' to get all threads
that are "alive" in the GC sense.
Matthew