Small Java Threading Library

Hello everyone!

I’ve created a small library to make threading games easier. This is done by putting the game logic in task objects and setting which tasks that has to be run before a specific task can be run. It’s also possible to multithread a single task.

Anyway, the Google Code project is here: http://code.google.com/p/small-java-threading-library/ The source code is obviously also available, and there’s Javadoc for all accessible methods. There’s also two test programs that you can check out in the source code.

I hope someone finds it useful!

Wrong folder - the project belongs to be in trunk, not in the top level.

  • Trunk - the location where your main project files live.
  • Branches – individual copies of the project. These can be used to maintain bugfix releases of older versions or to prototype more fundamental changes to the codebase without interfering with the daily development on the trunk. Branches can be merged to the trunk semi-automatically.
  • Tags - copies of the project to mark certain milestones like release versions.

_< I’ve managed to copy it to trunk, but I don’t seem to be able to remove the old files… Geh, too tired…

Hello there,

I am new to Java game development and am working on my first game. I came across your Thread Library after searching how to fix stutter issues. Right now I have a variable timestep loop setup but my game still stutters occasionally. I was wondering if separating game logic from rendering in separate threads would help my problem. Could you show me how you would go about doing that with your library? Is that even a good idea?

Thanks.

Stutter issues can be caused by many things and are not solved by introducing threading. So far the two main culprits for a stutter in my games have been to screw up the timing of my game loop and to use integers for movement speed and positioning where I should have been using floats.

No, sorry. Like Gimbal said, the problem is most likely something else. This library just allows you to cram out (a lot) more performance from multicore CPUs. This library is more flexible than just separating rendering and updating into different threads. It allows you to do task level parallelism, for example:

Render terrain Update objects
in graphics thread (3 threads)
| | | |
| | | |
| Update AI Handle collisions
| | | |
| | | |
| | | |
| | | |
Render all objects after all other tasks complete
|
|
|

So a Thread Pool + Prioritized Task Manager? Sweet.

Thanks for the replies! I guess I’ll keep looking for other reasons why my game is stuttering. I might look into threading as my game gets more complex though.

Can I use this with Slick2D?

I think so, but I don’t know much about Slick2D. As long as you only call Slick (and OpenGL) functions in DrawTasks it should work.