JAVA multi-threaded high-concurrency face questions summary

ReadMe : brackets, with the addition or explanation.

Multi-threaded and highly concurrent post-graduation job interview will ask manufacturers of knowledge, always just go to the relevant knowledge to face questions back to back, every other period of time forgot, did not settle down before the interview before her, so himself summed up under the relevant knowledge points.

Multithreading

1. What is the difference between processes and threads?

  Process is an independent operating environment, it can be seen as a program or an application. The thread is a task carried out in the process. Process operating system is the basic unit for resource allocation, and the thread is the basic unit of the operating system scheduling. Let concurrent process of the operating system possible, and let the internal processes of concurrent threads possible. Like the Java Runtime Environment is a (contain different classes and programs) a single process.

Want to understand more deeply, please click on the difference between processes and threads

2. Thread class start () and run () method What is the difference?

   1)  Start () is used to start a new thread , run () can not .

   2) start () can not be called repeatedly, run () can.

   3) Start () RUN code can not continue execution after executing the following code, that thread conversion, if called directly run () must wait for the completion of the implementation of all of its code in order to continue with the following code.

   4) start () to achieve a multi-threaded , run () is not multi-threaded .

3. In the multi-thread, what is the context switch?

  Context switch is to store and restore the CPU state of a process, a thread of execution such that it is possible to resume execution from the interruption point. It is the basic feature of multi-tasking operating systems and multi-threaded environments.

What 4. Java in the volatile variables?

volatile is a special modifier only member variables ( member variables of the class, the class of static member variables ) in order to use it.

Is volatile then modified to have two layers of semantics:

  1 ) to ensure visibility when different threads to this variable operation ( ie one thread modifies the value of a variable, this new value to other thread is immediately visible ) .

       2 ) prohibition command reordering.

 

 

High concurrency

Guess you like

Origin www.cnblogs.com/liaowenhui/p/11184884.html