Close resources before exiting JFrame and TCP communication in Java
- by Oz Molaim
1.
I'm writing a chat based application on TCP communication.
I'm using NetBeans and I want to add functionality to the default EXIT_ON_CLOSE when exiting JFrame.
The reason of course is because I want to clean resources and end threads safely.
How can I call a method that clear resources and only then close the JFrame safely and end the process.
2.
I need to implement the server side. The server has List/HashMap/Queue of 'Socket' with their chat nick-names. Is there any simple design pattern to do it correctly because I don't want to re-invent the wheel.
thanks.