[Solved] How to update the translation of a node using BasicGameState

I created a thread that updates the position of a node (Using the StandardGame Method); however, it seems like this thread stops when it tries to call the GameTaskQueueManager.  I  have listed two classes below.  The first class is the thread that updates the position of a node.  The second class is the Collable that is sent to the GametaskQueueManager. 



What am I doing wrong?


   public class UpdatePosition extends Thread{
        Vector3f vec;
        Node node;
        public UpdatePosition(Node node){
            vec = new Vector3f();
            this.node = node;
            start();
        }
        public void run(){
            try{
                sleep(1000);
                vec.x += 0.01f;
                GameTaskQueueManager.getManager().update(new LockNode(node)).get();
                node.setLocalTranslation(vec);
            }catch(Exception e){}
        }
    }



   public class LockNode implements Callable{
        private Node node;
        public LockNode(Node node){
            this.node = node;
        }
        public Object call() throws Exception{
            node.lockBounds();
            return null;
        }
    }

To answer my own question … I'm not sure why locking the node doesn't work … but what I realized is that updating the translation of a node must be done in the game loop.  So in order to do that, you have to use the GameTaskQueueManager and a Callable class.



So something like what I have posted below accomplishes that.  Also note, you can't use the .get() method on the GameTaskQueueManager because it will lock this thread.  Again, I'm not sure why.



    public class UpPosition implements Callable{
        Vector3f vec;
        Node node;
        public UpPosition(Vector3f vec, Node node){
            this.vec = vec;
            this.node = node;
        }
        public Object call() throws Exception {
            node.setLocalTranslation(vec);
            return null;
        }
    }




        public void run(){
            try{
                while(true){
                    sleep(1000);
                    vec.y += 0.1f;
                    GameTaskQueueManager.getManager().update(new UpPosition(vec,node));
                }
            }catch(Exception e){}
        }
    }

Conzar said:

Also note, you can't use the .get() method on the GameTaskQueueManager because it will lock this thread.  Again, I'm not sure why.


The GameTaskQueueManager uses a single thread. If you block with .get() while in that thread, you've blocked the only thread that processes items on the queue. The task you submit and are waiting for will never execute because it hasn't complete the current task you are in. Make sense? Sometimes it is difficult to explain these things.

I think so.  So when would you want to block with the get method?