I think there are several problems here, but the bottom like is: be upfront
about sharing data, hidden shared data may not give the user the tool they
expect.<p/>
In the following:
<pre>
public Integer get_bigdata() {
if (_static_bigdata == null) {
log("alloc"); // from ant Task class
_static_bigdata = new Integer(0);
}
return _static_bigdata;
}
</pre>
You have unsynchronized lazy init, the "if" block should be synchronized.
(Or use
<pre>
static {
_static_bigdata = new Integer(0);
};
</pre>
for load time init).
That may not solve your problem, but static lazy init blocks should be lock
protected.
<p/>
On your other question, yes if the class is reloaded; the static
initializers will run again. Consider placing your data into properties.
This would also allow the user to control the shared data block.
--
View this message in context:
http://ant.1045680.n5.nabble.com/How-do-I-share-data-between-custom-Ant-tasks-tp3235670p3236384.html
Sent from the Ant - Dev mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]