Processing 4 and JDK 19 Virtual Threads

Hi all.

I would like to use Virtual Threads in my game.
Do you know if Processing 4 is compatible with JDK 19?

My game seems to consistently hover around 22fps at the moment while the computers CPU/RAM/GPU are not close to being maxed out. Apart from loading files at specific times there are no blocking calls. I wrote a keyboard event handler that will disable the animations for the water tiles that I have in my game and the fps jumps up to 30+ fps.

It seems processings animation thread is maxing one cpu core on my i5 and can not make use of the other cores. I am using the P2D renderer which is hardware accelerated. So I’m hoping if I use virtual threads throughout my own code to free up some of that 1 cpu for processing it will fix this issue.

I asked ChatGPT and I did some googling before asking.

Thank you!

1 Like

Hi @Enda,

Nearly everywhere mentioned on processing sites… :wink:

— mnse

Hi mnse,

I did see that already but cheers.

It is still not clear if processing 4.x is compatible with later releases of the JDK like 18,19, 20.

Are new JDKs backwards compatible with the existing Java ecosystem or do they break everything including Processing ?


Hello @Enda,

This will provide some insight:


Hi @Enda,

Processing environment is shipped with its own java bundle, which is currently based on jdk 17.
Nevertheless you can try out yourself if it would work using a higher jdk version, but there are no guarantee it does …

— mnse

1 Like

My guess is that multi-threading your game would make it significantly more complicated while probably not improving the speed very much if at all.

Nearly all of the time spent in nearly all programs is waiting for memory accesses. For speed, you’ll want to do what you can to simplify and minimize memory accesses in your innermost loops. As an example, it is much faster to update a flat array of floats or ints than it is to chase object pointers to PVectors and newing new PVectors in the process. This youtube talk does a great job of showing how relatively simple changes to the way you think about and organize your data can have a big impact on performance.

Similarly, graphics calls are significantly faster if you can batch them into fewer, larger calls. Drawing a PShape, for instance, is much faster than drawing all of its separate pieces each frame. If you are creating a tile or sprite based game, you could get a big boost by using a large single tile atlas image and drawing your sprites as textured polygons that index into it.

How are you currently drawing your water tile animations? Maybe we can help you tweak their performance.