"Turn" to preach Wisdom podcast Chengdu Java Training Center student notes!
Threads:
the static int max_priority thread can have the highest priority.
the static int min_priority the lowest priority that a thread can have.
int norm_priority The default priority assigned to the thread.
threads do not make strict requirements;
however: at least you need to know the two ways to create and start the thread, and can distinguish between two kinds of similarities and differences;
static Thread CurrentThread ()
setName (String name) sets the name of the current thread
getName (); Get the thread name
setpriority (int i); Set Priority
int getpriority () returns the priority of the thread.
boolean isAlive () tests whether the thread is active.
boolean Isdaemon () tests whether the thread is a daemon thread.
void Setdaemaon (True): Indicates setting a background thread
Sleep (Sleep), join (Rob), Yield (comity) ,
Start Method: Start ();
New Thread (Runnable R). Start ();
Subclass of New Thread (). Start ();
Sync: Three ways:
Synchronizing code blocks:
synchronized (obj) {
NewObject ()
//obj represents the same listener object
//code that needs to be synchronized
}
Synchronization method:
synchronized method .......
{
}
can be re-entered lock:
Reentrantlock
class a{
private Final Reentrantlock lock = new Reentrantlock ();
Public Void Show () {
Lock.lock ();//Lock
try{
//may appear out of sync code
}finally{
Lock.unlock ();//whether lock
}
}
}
thread communication: Relationship between producer and consumer
deadlock: Develop traditional Chinese medicine to avoid deadlock
In the written interview, the company that installed B likes to test;
thread and Process concepts: multiple backs before the interview
There is a few written tests, but they are often shown to show off:
producers and Consumers
Sync:
the three methods in object:
wait ();//Waiting
notify ();//wakes up a thread. I can't wake myself up
notifyall ();//Wake up all the threads
Chengdu Wisdom Podcast, professional Java training organization, Chengdu Android Training, Chengdu Java training First Choice Chengdu Preach Wisdom podcast!
Java Self-study material-thread