r/java • u/alexp_lt • Apr 21 '26
CheerpJ 4.3 - Run unmodified Java applications in the browser
https://labs.leaningtech.com/blog/cheerpj-4.3
84
Upvotes
r/java • u/alexp_lt • Apr 21 '26
View all comments
Show parent comment
2
u/koflerdavid Apr 24 '26
Applications running in the browser are single-threaded and can only sort-of do concurrency by using continuations. CheerpJ probably implements threading by implementing all threads as Virtual Threads, with the browser's event loop acting as the carrier thread. Although it would in theory be possible to implement true threading using Web Workers and allocating all memory in SharedArrayBuffers, which can cooperatively accessed by multiple browser threads, but good performance probably requires compiling everything to WebAssembly.