Object not returned in time allocated. When using future.get()

Me again with yet another thing. :stuck_out_tongue:

I’m using the following to pin the stars on the canvas at start up and it works good. Because the part that was calling this part was threaded it wouldn’t work, as expected.


private void pinStars(final TreeNode nodeID) throws IOException, InterruptedException, ExecutionException, TimeoutException {

Future fut = app.enqueue(new Callable() {


public Object call() throws Exception {

System.out.println(“In pinStars()”);

visibleStars = galaxy.getStarsToDraw(ocList, nodeID);

for (int j=0,k=visibleStars.size();j<k;j++) {


sun = new Mesh();



sun.setBuffer(Type.Position, 3, BufferUtils.createFloatBuffer(visibleStars.get(j).getXYZ()));

Material mat = new Material(Game.getGameAssetManager(), “Common/MatDefs/Misc/SolidColor.j3md”);

mat.setColor(“m_Color”, visibleStars.get(j).getColor());

Geometry ptSun = new Geometry(“pt_sun”, sun);





return this;





But during the play of the game, if I change leaf in my octree and pinStars (above) gets called, the thread gets parked and never comes back. After the first times of testing, I realized that by the second time it would be called, it would be from the main thread, so I decided to put the (500, TimeUnit.MILLISECONDS). It… kinda works. That new leaf’s stars appear on the canvas, but something crashes. It’s not the renderer though. But the only thing I can do is move the camera around. The ship doesn’t respond at all.

I have no idea how to fix that except maybe make a copy of that method but out of Callabe and only use it once the game is running. But I’d prefer not to do that.


EDIT: Whoops! Forgot to put the error message. That might help. :slight_smile:


Nov 22, 2010 10:31:32 PM stellarconquest.Game update

SEVERE: null

java.util.concurrent.TimeoutException: Object not returned in time allocated.

at com.jme3.app.AppTask.get(AppTask.java:109)

at stellarconquest.Game.pinStars(Game.java:418)

at stellarconquest.Game.updateViewTree(Game.java:329)

at stellarconquest.Game.update(Game.java:274)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.runLoop(LwjglAbstractDisplay.java:144)

at com.jme3.system.lwjgl.LwjglDisplay.runLoop(LwjglDisplay.java:141)

at com.jme3.system.lwjgl.LwjglAbstractDisplay.run(LwjglAbstractDisplay.java:198)

at java.lang.Thread.run(Thread.java:662)


Enqueueing the callable and then getting is blocking the current thread. When you are doing this on the render thread, you are blocking it and it is the thread that is supposed to call your Callable, so it can never do so. You created a deadlock. Simply canceling the task will not execute it.

Yeah. That was silly of me to ask that question. I realized it after posting the edit but at that point it was too late. :frowning: