Drop use of ThreadLocal, which causes class loader leaks.

This reverts the main part of 0c6089be9dad12bd5902b0a54591319885cafd47.  The reason for using a ThreadLocal isn't given in the original commit.  The terminal is a global resource and the use of ThreadLocal causes class loader leaks, so this pull request removes the ThreadLocal.