Multi-threading Clarification

Hi guys,

Say I have a method A that calls two other methods B, and C that both generate dozens of spatials and nodes at once - just once, and I call the that by taking several integer inputs from a server message.

Taking this as reference:

Can I just encapsulate those integer inputs inside a “Data” class, and return that with ‘future.get()’?

Sorry about how absolutely retarded this question is, I think this is the right way to do it - but I’ve been looking at the tutorial and following it step by step for a few days and still haven’t gotten it working.

Thanks in advance guys!

What would the future be? It’s the server thread that has the ints, right?

Actually, before I start spouting 6 different possible solutions to your potential problems… can you just explain more specifically what you are trying to do?

I think future.get() is probably backwards.

1 Like

Thanks for the prompt response!

Basically, I get a message from the server which contains 4 int values - and I take those int values as parameters for a method within the client that generates many spatials/nodes within the client.

Do you want the generation to happen on the render thread or just the attachment?

1 Like

Inside the render thread.

Then wrap your ints in a Callable that does the loading and enqueue with the application. It will be run on the render thread. No need to do a future.get() unless you somehow need the response… but if so then there are a dozen better ways to do this that won’t block a thread waiting.

1 Like

So this:

private Callable<Integer> renderBoard= new Callable<Integer>(){
    public int call() throws Exception {
        int aCopy = 
        application.enqueue(new Callable<Integer>() { 
            public int call() throws Exception {
                return a;
        //render the board here using the copied integer
        return 0;

It works! Just got back home and tested it out!