Miguel,
What I meant was that the check for null array must be within the
synchronized method initialize(), not in the constructor. So the two
changes I effected were
a) static added for initialize(), as per Nico's excellent observation
b) remove check for null in the Geodesic3D constructor:
Geodesic3D(Graphics3D g3d) {
this.g3d = g3d;
initialize();
}
private static synchronized void initialize() {
if(vertexCounts != null)
return;
vertexCounts = new short[maxLevel];
....
}
Do you see what the problem was in having the check for null in the
constructor itself?
Sorry about the confusion with constructors -- a book I have seemed to
suggest that threads cannot yield while constructing, but that's
obviously a misreading on my part.
The problem was definitely in the missing static keyword, which Nico
found... and the misplaced check for the start of initialization, which
must appear ONLY within the synchronized method itself, not allowing a
bypass of that synchronization. That's because if a second thread is
allowed to bypass initialize() and not sync there, waiting for the first
thread to complete, then it can skip right to code in Isosurface that
requires those normals prior to the first thread completing the
initialization. Right?
Bob
Bob
Miguel wrote:
>>the other fix added is to make sure that initialize() IS run by every
>>thread, so that the synchronize is encountered, not escaped in the case
>>that the array being constructed is null. That does the job.
>>
>>Bob
>>
>>
>
>But it is not the case that the the initialize is "escaped in the case
>that the array being constructed is null".
>
>I think that you want that test for == null so that all the threads don't
>get repeatedly synchronized through the initialize() method.
>
>
>Miguel
>
>
>
>_______________________________________________
>Jmol-developers mailing list
>[email protected]
>https://lists.sourceforge.net/lists/listinfo/jmol-developers
>
>
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers