I am writing a chat program, and I am trying to figure out how to add in a timer that will disconnect the person after a certain period of time.
One class I have that accepts the chat string from the user and disconnects on request and whenever the client disconects unexpectedly, and will(hopefully) disconnect after x minutes. This class implements Runnable.
My first thought was a Timer class that implements runnable, and throws a TimedOutException. Problem is that run can not throw anything.
Is it possible/good idea, for Timer to inherit the class mentioned above, and run in a seperate thread?
Any suggestions or advice on disconnecting a Socket after a set time will be greatly appreciated.