Hi everyone,

All this talk on Threads has encouraged me to relate a problem I'm having with Java3D 
and Threads. Hopefully it's something I'm doing wrong that I can fix. 

My application essentially animates an articulated arm (a TransformGroup for each 
joint). The user drags a JSlider which sends data over a socket to a C application 
(historic kin/invkin engine that i must use), which processes the data quickly and 
sends joint data back over the socket to my Java app.

I have a few threads involved, but here's my basic scheme:

1) One thread continually reads the socket and updates a set of transforms in my 
Manipulator object. These transforms are not placed in the live Transform groups.

// This method is called by the socket-reading thread with new joint values
void synchronized Manipulator::setJointValues(double[] newJointValues)
{
    for (int j = 0; j < jointTransforms.length; j++) {
        jointTransforms[j].rotX(newJointValues[j]);
    }
}

2) A behaviour runs every 31ms and calls a synchronized "latchJoints" method on the 
Manipulator object which places the transforms into the live TransformGroups.

// This method is called from processStimulus of the behaviour
void synchronized Manipulator::latchJoints()
{
    for (int j = 0; j < jointTransforms.length; j++) {
        jointTG[j].setTransform(jointTransforms[j]);
    }
}

This works fine for a while, then eventually stalls the Java3D Behaviour thread. The 
socket-reading thread continues. It's worse with a smaller scene.

I have tried using the InputDevice mechanism but it had the same problem (albeit an 
older version of Java3D). I have also tried waking the behaviour after every frame, 
but it's much worse.

Alas, when I run the app in a debugger it never crashes! Typically Threading problem, 
right?

Unfortunately my app is too huge to be useful as a test app and I haven't the time 
right now to pare it down, but if anyone sees an obvious blunder on my part I'd 
appreciate some insight. I'd appreciate debugging strategies too.

Thanks everyone,
Josh


----------------------------------------------------
Joshua L. Richmond, BASc, MSc.  
Systems Engineering (R&D)

MD Robotics
9445 Airport Rd, Brampton, ON, Canada
(905) 790-2800 x4332
-----------------------------------------------------

BEGIN:VCARD
VERSION:2.1
X-GWTYPE:USER
FN:Josh Richmond
TEL;WORK:(905) 790-2800 x4332
ORG:MDRobotics Ltd.;Systems Engineering (R&D)
EMAIL;WORK;PREF;NGW:[EMAIL PROTECTED]
N:Richmond;Josh
TITLE:BASc., MSc.
ADR;INTL;WORK;PARCEL;POSTAL:;Mailstop 23;9445 Airport Rd;Brampton;ON;L6S 4J3;Canada
LABEL;INTL;WORK;PARCEL;POSTAL;ENCODING=QUOTED-PRINTABLE:Josh Richmond=0A=
Mailstop 23=0A=
9445 Airport Rd=0A=
Brampton, ON  L6S 4J3=0A=
Canada
LABEL;DOM;WORK;PARCEL;POSTAL;ENCODING=QUOTED-PRINTABLE:Josh Richmond=0A=
Mailstop 23=0A=
9445 Airport Rd=0A=
Brampton, ON  L6S 4J3
END:VCARD

Reply via email to