CSE 205 Lecture Notes - Lecture 26: Multiprocessing, Instance Variable, Java Virtual Machine

132 views3 pages
CSE 205 Lecture 26 Threads
Topics
o Java Threads and Runnables
o Running Threads
o Synchronization
What is a thread?
o An independent path of execution through program code
o When multiple threads execute byte-code instruction sequences in the same
program
Known as multithreading
Benefits of multithreading
o Multithreaded GUI-based programs
remain responsive to users while performing other tasks such as:
printing a document
opening a web browser
Threaded programs typically finish faster than their non-threaded
counterparts
Especially true of threads running on a multiprocessor machine,
where each thread has its own processor
Running Multi-Threads
o On a single processor, multithreading generally occurs by multitasking
The processor switches between different threads
o Java supports the creation of programs with concurrent flows of control
o The Java virtual machine (JVM) executes each thread for a short amount of time
and then switches to another thread
Thread class in Java.lang
o Java accomplishes multithreading through its java.lang.Thread class
o Each Thread object describes a single thread of execution
o The execution occurs in Thread’s run() method
Unlock document

This preview shows page 1 of the document.
Unlock all 3 pages and 3 million more documents.

Already have an account? Log in

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers