"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 the thread can have.
int norm_priority The default priority assigned to the thread.
the thread does 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.
The Boolean isAlive () test 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
during the written interview. The company that installed B likes to test;
thread and Process concepts: multiple backs before the interview
Another written test is not much, but they often 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 threads
Chengdu Wisdom Podcast, professional Java training institutions, Android training in Chengdu. Chengdu Java Training preferred the Chengdu Wisdom Podcast .
Java Self-study material-thread