7. Why are OS threads considered
expensive?
1. Starting and stopping them.
2. Keeping their stack around.
Source:https://www.cs.uic.edu/~jbell/CourseNotes/OperatingSystems/4_Threads.html
8. How many threads can I run?
Waiting for response.
Processing the
response.
Preparing the
request.
A thread is idle 99.99% of the time
1. Thread startup time: ~1ms (depending upon the CPU architecture)
2. On Linux/x86-32, the default stack size for a new thread is 2 megabytes: pthread_create
3. Context switching: ~100 µS (depending upon the CPU architecture)
ThreadCountTest.java
9. What is Project Loom?
Project Loom aims to drastically reduce the effort of writing, maintaining, and observing high-throughput
concurrent applications that make the best use of available hardware.
— Ron Pressler (Tech lead, Project Loom)
1. A STANDARD Java Platform Thread is a thin wrapper on an Operating System Thread. [1:1]
2. A Virtual Thread is not attached to any particular OS thread [M:N]
11. Continuations
yield() copies stack to heap!!
When freezing, all Java stack
frames (as opposed to native
frames running the JVM) must
be stored somewhere safe, so
they can be restored when
"thawing"
ContinuationDemo.java
12. Limitation of Virtual Threads
Thread Synchronisation
LockedThread.java
SyncedThread.java
13. Issues with Reactive Programming
Brian Goetz: "I think
Project Loom is going
to kill Reactive
Programming"
Program Complexity vs Scalability Source:developers.redhat.com