From: "Brad Urani" <[EMAIL PROTECTED]> Sent: Thursday, May 23, 2002 7:36 PM
> I have a program that calls Behavior.postId() in a > thread with waits like so. > > for(c=0; c<100; c++) > { > behavior.postId(1); > Thread.sleep(20); > wait(); > } > > The behavior class calls notify() when it finishes so > the loop can continue, But I've noticed that if I set > the sleep too low the 3D thread will miss the behavior > post and get stuck at the wait() freezing my program. > Does anyone know how to guard against missed posts > like this? I've been holding off a bit on this, hoping for an answer from someone who knew something about threads. I haven't figured my way around Java threads, but I have learned to avoid tricky wait/notify structures like the plague, and, most especially, I wouldn't let them near J3D. I can't read your exact problem here, but I can say that you're working in a frequency range that is very close to the one used by the J3D Behavior scheduler to poll its wakeup queue so I think you can expect trouble (the way this works is undocumented so I'm just guessing based on testing and observation, and in fact, I'm pretty sure it changed from 1.2 to 1.3) Further, I'm pretty sure that when a Behavior wakes up, it flushes its queue, so you're responsible for dissecting the wakeup condition and feeding its components to the proper response methods. At least this is the only way I've gotten my Behaviors to work reliably. YMMV. So if your postId was stacked up behind another wakeup and you didn't handle the sequence properly, you may miss it, and your program would hang in the wait(). If you're trying to do something about timing Behaviors or sequencing sampling, then I think you'd be much better off moving everything onto a Behavior. Not much, but I hope this helps. Fred Klingener Brock Engineering =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA3D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".