Once my server accepts a connection, a thread is started to work on the client data, while the server returns to accept futher connections.
This is working pretty well...
until yesterday, that is.
I needed to modify my "worker" thread. It now has included a class that is not threaded and needs to invoke one of that classes non-threadded methods.
Something like this:
Now the problem I'm seeing is that myOtherCLass.doSomeWork is being inundated with "clientData" from the multitude of worker threads.
I thought that all I needed to do was to modify the doSomeWork method from this:
But this has had no affect.
Joined: Mar 06, 2001
Is there any particular reason why you care if the static method is being invoked by many threads?. As long as the method is operating on the variables local to that method, it should be fine. Do you feel that the method is not thread safe and hence you want to make it synchronized?
I mean the fact that the method is being accessed by multiple threads simultaneously s'dn't bother you as long as it is thread safe.
Joined: Jul 12, 2004
Originally posted by jefff willis:
You must keep in mind that local variables are thread safe, while static and instance fields are not.