Java Self-study material-thread

Source: Internet
Author: User

"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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.