Yes, this would be cleaner, but we'd need to be careful that
Thread.join() etc don't try to access the native state after it has been
freed. To avoid race problems here we could perhaps register the
finializer on the native state (natThread) itself rather than the
java.lang.Thread, and atomically release it (set "thread->nt" to null)
when the thread dies.
Believe it or not, my initial iteration attempted to clean up the native
state when the thread died, but:
- I didn't know what to synchronize on.
- I figured it would require synchronizing on something every time we
needed to access the native state, which would unnecessary penalize
everyone because of the fringe case of troublemakers trying to
resurrect a thread.