# Processing 4 and JDK 19 Virtual Threads

**URL:** <https://discourse.processing.org/t/processing-4-and-jdk-19-virtual-threads/41734>\
**Category:** Project Guidance\
**Created:** [April 16, 2023, 6:19am UTC](https://discourse.processing.org/t/processing-4-and-jdk-19-virtual-threads/41734 "2023-04-16T06:19:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Enda](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/enda/32/16566_2.png) [@Enda](https://discourse.processing.org/u/Enda)\
**Post date:** [April 16, 2023, 6:19am UTC](https://discourse.processing.org/t/processing-4-and-jdk-19-virtual-threads/41734/1 "2023-04-16T06:19:24Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [April 16, 2023, 11:31am UTC](https://discourse.processing.org/t/processing-4-and-jdk-19-virtual-threads/41734/2 "2023-04-16T11:31:28Z")

</div>

Hi @Enda,

Nearly everywhere mentioned on processing sites… 😉

 ![Screenshot_20230416_132815_Samsung Internet](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/7/b/7b698b5e05c132bb6742b14a9d85d41a64b72ed6.jpeg)

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![Enda](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/enda/32/16566_2.png) [@Enda](https://discourse.processing.org/u/Enda)\
**Post date:** [April 16, 2023, 12:39pm UTC](https://discourse.processing.org/t/processing-4-and-jdk-19-virtual-threads/41734/3 "2023-04-16T12:39:01Z")

</div>

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 ?

Regards  
Enda

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [April 16, 2023, 1:16pm UTC](https://discourse.processing.org/t/processing-4-and-jdk-19-virtual-threads/41734/4 "2023-04-16T13:16:20Z")

</div>

Hello @Enda,

> [@Enda](#):
>
> Do you know if Processing 4 is compatible with JDK 19?

This will provide some insight:

> **[GitHub - benfry/processing4: Processing 4.x releases for Java 17](https://github.com/benfry/processing4)**
>
> Processing 4.x releases for Java 17. Contribute to benfry/processing4 development by creating an account on GitHub.

`:)`

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [April 16, 2023, 1:22pm UTC](https://discourse.processing.org/t/processing-4-and-jdk-19-virtual-threads/41734/5 "2023-04-16T13:22:44Z")

</div>

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 …

Cheers  
— mnse

---

<div class="post-metadata">

**Author:** ![scudly](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/scudly/32/5597_2.png) [@scudly](https://discourse.processing.org/u/scudly)\
**Post date:** [April 16, 2023, 9:04pm UTC](https://discourse.processing.org/t/processing-4-and-jdk-19-virtual-threads/41734/6 "2023-04-16T21:04:16Z")

</div>

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 `float`s or `int`s than it is to chase object pointers to PVectors and `new`ing new PVectors in the process. [This youtube talk](https://www.youtube.com/watch?v=NAVbI1HIzCE) 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.
