Original Post
Recently I created a small 2D game in Java that is a clone of the game Puyo, a game similar to Tetris. I have a strong background in creating games with C++ and so I knew largely what I wanted to do code-wise. Starting out, I had googled for "java game loop" to get an idea for how the basic structure works. Every site I read seemed to do the same thing. A new thread was spawned and the game loop would take place there. Rather than spend time thinking about the implications of this I just mimicked it and got the game done. Now that I have time to reflect on what I have coded, this doesn't seem to make sense. A few more google searches and I found some programmers claiming that a reason for the new thread is to gain the ability to sleep it. Input they say, is captured by a seperate thread which Java has automatically spawned upon execution of the program. That, in order for it to be processed the thread which I manage must be slept (or at least a sleep(0) must be made) or input won't ever get through. However, from what I can tell this is not true. Regardless of whether or not I sleep my thread I still receive and process input. Note I am implementing KeyListener. Is this a result of Java halting my thread so that the code to handle key events can be run? I would appreciate some gritty details as to how input actually works in Java, and how it should properly get processed in a game loop. Since many people seem to program their game loops very differently depending on whether they are making a 2D or 3D game, please provide me with answers that apply to working with a 3D game.