Skip to content

An experiment with Java21 Virtual Threads and Clojure

Notifications You must be signed in to change notification settings

bryanmikaelian/clj-virtual-threads

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 

Repository files navigation

clj-virtual-threads

An experiment with Java21 Virtual Threads and Clojure. Both examples just update an atom counter over 100000 threads, comparing the execution time between a virtual thread and a "real" thread.

Disclaimer

This was a very quick thought experiment but there are some issues. Take these numbers with a grain of salt See this hacker news thread

Running

Using the Clojure CLI, you can run this program like so:

clj src/main.clj

Results

M3 Mac

CleanShot 2024-07-31 at 10 49 58

count:  100000
virtual start time (ms):  1722446540075
virtual end time (ms):  1722446540306
virtual elapsed time (ms):  231
count:  100000
real start time (ms):  1722446540311
real end time (ms):  1722446543667
real elapsed time (ms):  3356

Intel Mac

Screen Shot 2024-07-31 at 2 13 07 PM
count:  100000
virtual start time (ms):  1722449512852
virtual end time (ms):  1722449513318
virtual elapsed time (ms):  466
count:  100000
real start time (ms):  1722449513330
real end time (ms):  1722449520618
real elapsed time (ms):  7288

About

An experiment with Java21 Virtual Threads and Clojure

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published