passing parameter to a thread
I am trying to write a simple multithreaded server-client application.
Application logic is as follows:
server opens a socket for each client.
server starts a thread for each client.
for each client in a loop
-server sleeps arbitrary time (random duration)
-after sleeping server sends an arbitrary message(random message)
If i want to start a thread whenever server sends a message to client there is no problem.
But what i want to do is creating 1 thread per 1 socket (client) (not per 1 message)
and send arbitrary message using this thread.
The problem is i am not able to pass my arbitrary message to a thread which has already started.
what might be the solution?