Re: ThreadPoolExecutor backport



Philipp wrote:
I'm using the backport to java 1.4 of Doug Lea's java.util.concurrent

Just out of curiosity, why are you stuck with an obsolete version of Java?

package. In the doc for ThreadPoolExecutor, there is a snipped of code

It's "snippet". "Snipped" is the past participle of "to snip".

to build a pausable thread pool executor. The snipped is below.
Q: Why does the boolean flag isPaused need not be volatile?
As I see it, it will be polled and set by different threads and
nothing guarantees a memory barrier.

Nothing but the 'pauseLock.lock()', that is.

Q2: Does it make a difference if you are in the 1.4 or java [sic] 5
memory model?

Yes, but not to this snippet.

--
Lew
.



Relevant Pages

  • Which functions act as memory barriers?
    ... the compiler can optimize and load shared ... Therefore, declaring shared_data as volatile ... And where can I read about this memory barrier concept? ...
    (comp.lang.c)
  • Re: C Programmer Needed
    ... >> buffering messages between two threads. ... >> the compiler this is to mark the array as volatile. ... tion will provide a memory barrier at a volatile access. ... the new Java memory-access semantics that arrived with Java 5, ...
    (comp.programming)
  • Re: volatile and win32 multithreading
    ... Declare it volatile. ... idea that volatile suppresses optimizations and forces the compiler to go to ... Compilers typically don't confer memory barrier ... In addition to providing mutual exclusion, the mutex lock/unlock operations ...
    (microsoft.public.vc.language)
  • Re: MemoryBarrier vs volatile vs lock
    ... volatile field is about the same performance as non volatile ... Memory Barrier and VolatileMethods are about twice as slow ... locked is 7 times slower and slower than a memory barier ...
    (microsoft.public.dotnet.general)
  • Re: Good practice for an approximation algorithm with start & stop features
    ... > dealing with different languages all the time. ... > the difference of volatile in these languages because the languages look ... > When you speak of locking, you mean that you would use a locking ... memory barrier when acquiring, and a write memory barrier when ...
    (microsoft.public.dotnet.languages.csharp)