"any single-threaded program is also a valid multi-threaded program"
Without going to the book or reading the section, there are many ways for a single-threaded application to be multi-threaded when working in the JVM. There are several specific JVM threads that deploy when the JVM starts. They include gc threads, finalizer, JMX threads (if included) and others. These threads run in the background to help the JVM work efficiently.
For example, in my OSX block, the following threads are deployed by default:
- Main
- Link handler
- Finalizer
- Signal Manager
- Attach Listener
- A series of RMI and JMX threads if JMX is enabled
In addition, since the main thread executing the user application code encounters synchronized , blocks, or accesses volatile fields in libraries or JDKs, then the main thread goes through memory barriers, captures and releases locks, etc., as a multi-threaded application. This may be a link to the author.
Finally, it is important to understand that the term "reentrant" was created before the concept of flows was even invented. The code must be properly written in order to be reentrant due to recursive methods or interrupt handlers, which meant that the code could be entered twice, even if it wasnβt for several "threads". This is necessary to write the correct reentrant code, it was necessary before switching the context, exchanging I / O, cache, etc. Yes, I show my age here.
source share