Thread.getState() very slow
Doug Lea
dl at cs.oswego.edu
Sat Jul 10 13:35:31 UTC 2010
I've been trying out some improvements in ForkJoin
that involve repeatedly scanning threads to check
whether they are still in state Thread.State.RUNNABLE.
This is shockingly slow because getState() is implemented
using a lookup table that requires a global lock
(to ensure initialization) plus boxing to do the lookup.
Practically any other implementation would be faster.
For example, simply scanning the small static array of
sun.misc.VM.getThreadStateValues. And surely there are
better ways.
Is anyone looking into this?
Or alternatively, is there a faster way to check that
internal field Thread.threadStatus has the value mapping
to RUNNABLE?
If not, I might try contributing a patch.
-Doug
More information about the core-libs-dev
mailing list