The purpose of multithreading is to maximize the utilization of CPU resources. Java writers run in the Java Virtual Machine (JVM), and within the JVM, the multitasking of the program is done through threads. Starting a Java application with Java commands starts a JVM process. In the same JVM process, there is only one process, which is itself. In this JVM environment, all program code runs as threads. A Java virtual machine allows an application to run multiple execution threads concurrently. The Java language provides extensibility points for multithreaded programming and gives a powerful threading control API. In Java, there are two ways to implement multithreading: extending the Java.lang.Thread class to implement the Java.lang.Runnable interface Java Multi-Threading disadvantage: 1, Java data Synchronization is achieved through synchronized, But basically to the virtual machine to complete, 2, the Java Multi-threaded run method does not return a value, so how to get the child thread feedback information, it really makes a headache.
Talk about Java Multithreading (interview)