You can get thread information using ThreadLocal variables . I don't know anything about the details of Rhino or log4j, but I think they do that.
An example from Javadoc that assigns a different serial number to each serial number.
public class SerialNum {
private static int nextSerialNum = 0;
private static ThreadLocal serialNum = new ThreadLocal() {
protected synchronized Object initialValue() {
return new Integer(nextSerialNum++);
}
};
public static int get() {
return ((Integer) (serialNum.get())).intValue();
}
}
source
share