The fields in InfoSocket
shouldn't be static
. That is why it overwrites the memory the second time you call it. If they were not static
, each InfoSocket
instance would have its own copy of those variables.
By the way, there is no need to write:
Runnable infRunnable = infSocket;
An InfoSocket
is already Runnable
. You can simply write:
Thread infSockeThread = new Thread(infSocket);