As simple as that: Don't access the scenegraph from more than one thread or synchronize your access.
A simple way to get an action into the main/game thread is via InputHandlers or Controllers. But you can use Runnables or Futures as well - or implement a custom way as well (e.g. in your game loop).
Using a thread for this is a really bad idea.
You should subclass Controller, increment some variable by tpf and when it reaches 10 you call removeFromParent() on the Node.
there is actually a TimedLifeController you can use.
you just have to implement the updatePercentage method.
@Override
public void updatePercentage(float percentComplete) {
if (percentComplete == 1.0f) {
object.removeFromParent();
}
}
Thanks so much everybody for the help. I just implemented the TimedLifeController, quickly and very elegantly. I was really on the wrong path using Threads for what I wanted.
Thanks again, the jME community and software is wonderful and I'm glad to be part of it.
best regards