This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
rajshkhr pandey wrote: How can I identify the thread corresponding to the user ...
Well, you could define e.g. a HashMap (username, created thread).
I guess this would be the easiest way ...
rajshkhr pandey wrote:... and how can I stop that thread?
You will have to declare some variable (usually a boolean), which is then checked in a loop (within a run method).
Beside this, you may also want to call an interrupt() ... just in case the thread is currently waiting or is blocked.
Just to amplify what Rok said - you have to design your run method so that it can be exited gracefully. There are many pitfalls if you try to just arbitrarily stop a Thread. Read the java.lang.Thread documentation carefully, especially the deprecated stop() method documentation.
If the user is formally logging out rather then just disconnecting, you already have the Thread corresponding to the user so clean up of resources and a graceful exit from run should be easy with a proper architecture.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com