The way it is written works, but creates a memory leak at the same timeThen don't do a while(true) inside Connect.
Implement a timeout. Sleep the thread, see if there is new data, sleep a bit more, and if new data doesn't enters in X amount of time, close the connection. run() method ends and Thread is GC'd.
Also, don't 'new' Threads willy nilly. Use executors. Fix the amount of threads you want to make to handle connections. Threads aren't cheap to make, nor cheap to maintain (10Mb per Thread instance IIRC).