jmeter-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vladimir Sitnikov <>
Subject Re: Why do Functions that only have values as instance variable synchronize execute ?
Date Thu, 16 Oct 2014 15:32:29 GMT
>JMeter was originally written for Java
>1.4 (or earlier); I think volatile did not offer the safe publication
>guarantee then.

That is correct, however see below.

> No, because the Java Memory Model only guarantees safe publication of
> a mutable field if the writer and reader synchronize on the same lock.

This is plain wrong. Here are a couple of "whys":
1) There are lots of cases when "safe publication" is guaranteed without
synchronization and/or volatiles (thread start/stop, final fields, etc)
2) Just synchronization on the same lock is not sufficient (see
"synchronizes-with" in the JMM)

See 17.4.5 of the java language specification [1]: A call to start() on a
thread happens-before any actions in the started thread.

Since JMeterThreads are started after all the variables are set/cloned (as
in program order of the main thread), then you are guaranteed to see a safe
view when running in JMeterThread.
This is safe even without volatiles and synchronization, even in java 1.4.


​Vladimir Sitnikov

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message