Add monitor to NamedThreadFactory

This PR adds a monitor to NamedThreadFactory, and makes sure it is used in as many places as possible, so that we can track thread counts in the various components that creates threads.