Should I just use one thread - the main thread?

When designing a game, apart from resource loading and very time-consuming tasks, does it make sense to just run the entire game on the main thread?

No. Game Logic is a very expensive task with Collision Detection included. If you are on EDT, it hangs your game after a bit of playing.

PS: You seem to be too much interested in Java2D and Swing. I won’t recommend them due to the cost of performance. But however, you can checkout my engine I’ve made years back (almost 4 years now) which uses Swing. It’s located here at https://code.google.com/p/game-engine-for-java/

I’m talking about having the entire game run on a non-EDT thread, not on the EDT.

Some people here recommend this approach, to only use one thread.

“As some other people said, keep it simple, single-threaded, don’t use invokeLater…”
“When developing Java2D, always use one thread”.

Do you disagree?

(And I will start using a library when I’ll get a bit more experienced :slight_smile: LWJGL seems very common and therefore reliable).

Yeah, it works, but not for bigger games. Your game will start lagging soon enough it becomes somewhat sophisticated. Also, knowledge on Java2D won’t help much in LWJGL, because it uses OpenGL. Java2D and OpenGL are two different APIs. So if you are thinking of learning LWJGL, I suggest my own tutorial series. Heres a link to the Contents page.

LWJGL Tutorial Series - Contents

Don’t care about performance if you don’t have issues.
Have you ever created a game?
No offence, just a little thought I have, a lot of people spend to much time on theorie and never get something done.

I think all of the games you see on jgo are perfectly fine with one thread. Using multithreading efficiently is quite hard and you might get a lot of troubles :slight_smile:

And java2D helps learning making games with lwjgl. You can learn how to render your game without having to setup all the screen related stuff in lwjgl.

But that’s the easy bit with LWJGL…

Cas :slight_smile:

Yes, I have made games :slight_smile: But not complex ones yet.

Until things get slow do NOT worry about this.

Fact is, unless you are actually making a ‘real’ game (not tinkering or some small project) you will never need to worry about multithreading your game.

Anecdotal evidence:

I’ve only just started to use threads in games after 12 years for our latest magnum opus, Battledroid, and only because we’re now dealing with entity counts in the thousands and sprite counts in the hundreds of thousands. All the games we made before it - even Revenge of the Titans with its hundreds of buildings and enemies and flying bullets - use a single thread. RoTT being the most complex, it used maybe a few thousand sprites in a typical frame. All our games run at a smooth 60Hz.

Cas :slight_smile: