Provide a proper way to remove thread-local variables

See #2483 and #2522

Motivation:

When Netty runs in a managed environment such as web application server,
Netty needs to provide an explicit way to remove the thread-local
variables it created to prevent class loader leaks.

Modifications:

- FastThreadLocal now keeps track of all thread local variables it has
  initialized, and calling FastThreadLocal.removeAll() will remove all
  thread-local variables of the caller thread.
- Added ThreadDeathWatcher.unwatch() so that PooledByteBufAllocator
  tells it to stop watching when its thread-local cache has been freed
  by FastThreadLocal.removeAll().
- Added FastThreadLocalTest to ensure that removeAll() works

Result:

A user can remove all thread-local variables Netty created, as long as
he or she did not exit from the current thread. (Note that there's no
way to remove a thread-local variable from outside of the thread.)

We can do that, but this makes DefaultThreadFactory useful for more use
cases, so that a user does not introduce another thread factory impl like
DecoratingThreadFactory.

Also, it's the place where we can decorate all runnables we use. Otherwise
we will have to duplicate this everywhere.
2014. 6. 17. 오후 8:51에 "Norman Maurer" <notifications@github.com>님이 작성:

> In common/src/main/java/io/netty/util/concurrent/DefaultThreadFactory.java:
>
> > @@ -123,4 +124,26 @@ public Thread newThread(Runnable r) {
> >      protected Thread newThread(Runnable r, String name) {
> >          return new FastThreadLocalThread(r, name);
> >      }
> > +
> > +    protected Runnable decorateRunnable(Runnable r) {
>
> why make it protected at all ? I think we just should decorate the
> Runnable before pass it to the ThreadFactory.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/netty/netty/pull/2578/files#r13854416>.
>