From the course: Advanced Java: Threads and Concurrency
Unlock the full course today
Join today to access over 24,800 courses taught by industry experts.
Platform threads versus virtual threads - Java Tutorial
From the course: Advanced Java: Threads and Concurrency
Platform threads versus virtual threads
- [Instructor] The regular Java threads or platform threads that we know of are thin wrappers around OS threads. It takes a lot to create and run platform threads. They require a large stack space and other platform or OS resources. Hence, they are costly to be created and executed. This is because platform threads are mapped one-to-one with OS threads. Despite this overhead of creating and running platform threads, they are easy to program and debug when using the thread-per-request pattern. Thread-per-request pattern means that the platform's unit of concurrency, which is a thread, maps directly to the applications unit of concurrency, that is a request. So each request is handled by a separate thread. However, the thread-per-request pattern limits the amount of requests a system can process in a given amount of time. In other words, the throughput. Due to this, the scalability of the system is hindered. This is because the number of platform threads that can be created is limited…