Exactly what you asked for, "something like a chat application". This IS a chat application. Your serversocket.accept() accepts a socket, delivers it into the class client() which is a thread. More @Wikipedia
Hover over any link to get a description of the article. Please note that search keywords are sometimes hidden within the full article and don't appear in the description or title.