1. Three ways to realize multithreading
1. Follow the thread class and cover the Run () method to
2.implements runnable Interface
3.implements Callale interface, execute with Futuretask to start thread
2, Thread synchronization method
Synchronized, lock
3, ThreadLocal
When you use threadlocal to maintain a variable, threadlocal provides a separate copy of the variable for each variable that uses the thread, so that each thread can operate its own copy of the variable independently.
There are four methods of threadlocal<t>:
void set (T value), setting the value of the thread local variable for the current thread
Public T GET, which returns the value of the copy of the variable that corresponds to the current thread
Remove from public void to delete the variable copy of the current thread
Protected TT Initalvalue (), returns the initial value of the copy of the thread variable. The first call to get or set on a thread executes only once.
Not to be continued ...
Java Interview Basics Summary (ii)---multithreading