|
Mon, 8 Feb
|
|
- JFC:
- Panels, Layout managers, Icons, JButton, JLabel
- Threads:
- multi-task computation, sometimes simulated
- allows use of more than one processor
- allows interleaving computation with blocked input/output
- writing code that blocks and waits is simpler, usually more
efficient, than spinning in a loop
- Thread class or Runnable interface
- usually just override/implement run() method, and perhaps
object constructor
- threads can be preempted (stopped) at any time
to allow other threads to execute
- example: printing thread
- Thread synchorization
- sometimes threads need to interact, access common
resources
- often need to ensure mutual exclusion, or use it to ensure
some other property
- can declare method to be synchronized
- only one thread can be inside synchronized code
- example: producer, consumer problem
- Reading:
- refer to Sun tutorials on
threads
- read about
synchronization in the Java Language Specification.
- On To Java: Ch 47
- Assignment #1 returned
|
|
|