logo       

RE: Reloading thread variables: msg#00017

java.jsr.166-concurrency

Subject: RE: Reloading thread variables

Jean,

This seems like excessive micro-optimization. Write the class using a
volatile and see if there is a performance problem. If so then try to figure
out ways of dealing with it.

> So, when the field value change, I'm wondering if restarting all threads
> (stoping live threads and creating new ones) that use this class would
> ensure that they see the new field value? If yes, I will not be forced
> to declare the field volatile (thus no overhead).

If the pattern is:

changeValue(int newval) {
stopAllThreadsButMe();
val = newval;
startNewThreads();
}

then yes the new threads will all see the new value. But the implied thread
management here would seem to impose its own significant overhead. And it
assumes you can stop all threads etc.

David Holmes


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise