Today, I learned Hibernate, see the data connection section, see a Threadlocal class, watching these two articles online.
Http://qszhuang.blogchina.com/blog/Article_20407.72483.html
http://www-900.ibm.com/developerWorks/cn/java/j-threads/index3.shtml#h5450
Discover Threadlocal is used to implement a thread local variable, a thread local variable is that each instance of thread has an instance of this variable. Each instance of the thread will not share this variable, or this variable is for threads. Examples are independent. In this case, there is no synchronization problem for such a variable, but it cannot be shared by the thread and cannot be used to communicate between each thread.
In Hibernate, net.sf.hibernate.Session is such a variable, servlet is a thread to establish a thread for each client, then, every one client, there will be a net.sf.hibernate Example of .Session. Net.sf.Hibernate.Session should be a session corresponding to a database connection. A session is corresponding to a connection to a database (cannot be sure, look at the Hibernate source in tomorrow), that is, in Hibernate, each client has a connection to the database.