Threadlocal is used to create session for everythread.It will make sure that everyuser accessing web page will get its own session. So here threadlocal is used basically to provide different session to different thread.
Just a note you should most likely not be writing code like that in your application anyway. Hibernate comes with a ThreadLocalSessionContext where sessions are tracked by thread of execution. This should be used for that use case rather than attempting to roll your own. This can be used by simply setting a hibernate property. Please see the reference documentation for more details.