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.
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.
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?
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.
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.
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;
}
}).get();
//render the board here using the copied integer
return 0;
}
};