Access over 20 million homework & study documents
search

Java Concurrency/Multithreading

Content type

User Generated

Subject

Programming

Type

Exam Practice

Rating

Showing Page:
1/24
Java 5 Concurrency

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/24
2 |
Table of Contents

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/24

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 24 pages?
Access Now

Unformatted Attachment Preview

Java 5 Concurrency Table of Contents 1. Creating Thread: 1.1 From Runnable: Thread t = new Thread(new R()); class R implements Runnable{ @Override public void run() { System.out.println("R done"); } } 1.2 From thread Thread t = new T(); class T extends Thread{ @Override public void run() { System.out.println("T done"); } } 2. Thread Functions 2.2 start(): public synchronized void start() 2.3 run(): public void run() 2.4 sleep(): public static native void sleep(long millis) throws InterruptedException; Thread.sleep causes the current thread to suspend execution for a specified period. This is an efficient means of making processor time available to the other threads of an application or other applications that might be running on a computer system. Two overloaded versions of sleep are provided: one that specifies the sleep time to the millisecond and one that specifies the sleep time to the nanosecond. However, these sleep times are not guaranteed to be precise, because they are limited by the facilities provided by the underlying OS. Also, the sleep period can be terminated by interrupts. In any case, you cannot assume that invoking sleep will suspend the thread for precisely the time period specified. Sleep throws InterruptedException when another thread interrupts the current thread while sleep is active. 2.5 interrupt(): public void interrupt() An interrupt is an indication to a thread that it shoul ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

Anonymous
Nice! Really impressed with the quality.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4