Tuesday 15 April 2014

java - Game loop using threads and synchronization -


I'm confused through the internet and my own code trying to write a game-loop (I'm picking up) .

I have applied the loop of the divinity but I decided that I did not interact with many different reasons. I did not find this practical solution.

However, I want to create two threads, one for updating is another one for rendering. I will regulate my execution with minimum and maximum looping intervals and calls for sleeping. Then everyone will have to deal with sync.

Is this a proper loop? Can any major problems arise?

It seems that I can think of the only implementation so far which will give me whatever things I am getting.

The idea of ​​running dual threads in this way is considered to increase performance but in reality it is applicable It is very difficult to do.

Obviously, you can not make both threads to reach the same objects and variables at the same time, so you try to make the setup synchronously rotate the thread, but then again Why do dual thread bother? This is self-defeating.

As long as your game is not really heavy and does not have a CPU account like any other business, then I execute the argument and render it on a thread, it's performance and performance Tune >

Just my 2 cents

No comments:

Post a Comment