Excellent analysis, Nico. That's got to be it.
OK, so here is the correct fix:
private static synchronized void initialize() {
if(vertexCounts != null)
return;
Simple as that. Yes, that works! SOOOO simple!
Very very good.
Bob
Nicolas Vervelle wrote:
> I think the initial problem (the fact that "synchronized" didn't seem
> to work) is the following :
> the initialize() method is synchronized but not static and each thread
> creates its own Geodesic3D object.
> So when each thread calls initialize() the "synchronized" doesn't
> prevent them to run concurrently because they run on different
> objects: it's a normal behaviour.
>
> If initialize() was static, there would be no problem
>
> [EMAIL PROTECTED] wrote:
>
>> Revision: 5212
>> Author: hansonr
>> Date: 2006-06-10 08:37:01 -0700 (Sat, 10 Jun 2006)
>> ViewCVS: http://svn.sourceforge.net/jmol/?rev=5212&view=rev
>>
>> Log Message:
>> -----------
>> bob200603 but with consequences for 10.3 if desired by others
>>
>> Geodesic synchronization (or lack thereof) causes pages with multiple
>> applets to fail to load some of those applets and generate a Normix
>> error.
>>
>> fixed using static flags rather than synchronization
>>
>> Testing on MSIE, Firefox, and Opera /Windows shows perfect
>> once-through synchronization per browser session.
>>
>> Modified Paths:
>> --------------
>> branches/bob200603/Jmol/src/org/jmol/g3d/Geodesic3D.java
>> Modified: branches/bob200603/Jmol/src/org/jmol/g3d/Geodesic3D.java
>> ===================================================================
>> --- branches/bob200603/Jmol/src/org/jmol/g3d/Geodesic3D.java
>> 2006-06-10 14:53:29 UTC (rev 5211)
>> +++ branches/bob200603/Jmol/src/org/jmol/g3d/Geodesic3D.java
>> 2006-06-10 15:37:01 UTC (rev 5212)
>> @@ -171,19 +171,35 @@
>> static short[][] faceVertexesArrays;
>> static Vector3f[] vertexVectors;
>>
>> - Geodesic3D(Graphics3D g3d) {
>> - this.g3d = g3d;
>> - if (vertexCounts == null)
>> + + Geodesic3D(Graphics3D g3d) {
>> + this.g3d = g3d;
>> + //String msg = "Geodesecs "+ System.currentTimeMillis();
>> + //System.out.println(msg+" 0");
>> initialize();
>> - }
>> + //System.out.println(msg+" 1");
>> + }
>>
>> - private synchronized void initialize() {
>> - if (vertexCounts != null)
>> + static Boolean[] testInit = new Boolean[1];
>> + private void initialize() {
>> + //System.out.println("geodesic init " + testInit[0] + " started");
>> + if (testInit[0] != null) {
>> + while (!testInit[0].booleanValue()) {
>> + try{
>> + Thread.sleep(10);
>> + } catch(Exception e) {
>> + System.out.println("geodesic constructor error "+e);
>> + }
>> + //System.out.println("geodesic init "+ testInit + " waiting");
>> + }
>> + //System.out.println("geodesic init skipped");
>> return;
>> + }
>> + testInit[0] = Boolean.FALSE;
>> + //System.out.println("geodesic init " + testInit + " continuing");
>> vertexCounts = new short[maxLevel];
>> neighborVertexesArrays = new short[maxLevel][];
>> faceVertexesArrays = new short[maxLevel][];
>> -
>> vertexVectors = new Vector3f[12];
>> vertexVectors[0] = new Vector3f(0, 0, halfRoot5);
>> for (int i = 0; i < 5; ++i) {
>> @@ -214,6 +230,8 @@
>> " edgeCount=" + getEdgeCount(i));
>> }
>> }
>> + System.out.println("geodesic initialization completed");
>> + testInit[0] = Boolean.TRUE;
>> }
>> static int getVertexCount(int level) {
>>
>>
>> This was sent by the SourceForge.net collaborative development
>> platform, the world's largest Open Source development site.
>>
>>
>>
>> _______________________________________________
>> Jmol-commits mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/jmol-commits
>>
>>
>>
>>
>>
>
_______________________________________________
Jmol-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-developers