Speed up thread start/end processing

It is not necessary to initialize any thread related data until an
exception occurs, and then we can skip calling getTid() in the thread end
callback.

Related to rhbz#1051198