SLIDE 1
1
1
Java threads: Introduction
2
Topics
- background, motivation, and benefits of threads
- what is a Java thread
– how to start a thread – how to stop a thread (if possible)
- on implementation of threads
– scheduling policies, priorities, etc.
- threads and interrupts
– on interrupting and stopping threads
3
Concurrent programming in Java
- in multiprocessing, multiple operating-system level
processes are used to execute (independent) programs – the programs execute in their own (usually protected) memory spaces, using their own (virtual) CPUs
- in multithreading, each thread also executes
concurrently, with its own logical copy of CPU (program counter, registers, stack, cache, etc.), – however, all threads can potentially share and access the same data (global objects) in the program
4
Concurrent programming (cont.)
- process ~ a concurrent execution of a program
(e.g., the Java virtual machine)
- thread ~ a concurrent control flow in the same
program (process)
- can involve either CPU interleaving vs. actual