I was going thru ThreadLocal class and found below example
public class UniqueThreadIdGenerator {
private static final AtomicInteger uniqueId = new AtomicInteger(0);
private static final ThreadLocal < Integer > uniqueNum =
new ThreadLocal < Integer > () {
@Override protected Integer initialValue() {
return uniqueId.getAndIncrement();
}
};
public static int getCurrentThreadId() {
return uniqueId.get();
}
} // UniqueThreadIdGenerator
Wondering the class ThreadLocal created above should be classified as inner class/anonymous class? Not Sure.
It’s an anonymous subclass of
ThreadLocal.An inner class is a class which is declared inside of another class declaration, using the
classkeyword. For example,Baris an inner class ofFoobelow: