![]() | ![]() | ![]() | 4.5 Week 5 - Threads |
Threads | Process | |
Memory Space | Shared | Seperate except with OS calls. |
Page Table | Shared | Seperate |
Registers | Stored on stack | Stored on stack |
Preempt-able | Maybe | Yes. |
Stacks | One per thread | One per thread |
Processes can have multiple threads. | ||
Task switch | "Fast" | "Slow" |
extends Thread
p. 254
implements Runnable
start()
. The method
start()
will then call your run()
.
start
ed once,
but you will not get an exception if you call start()
multiple times.
synchronized
can impact performance a LOT.
+=
operator is interruptible. Really.
synchronized
extends Thread
for three and the implements Runnable
for the
other three.
yield()
control after printing each
letter (or character and newline).
static
int
eger that will keep track of the
total number of letters printed. When a process "notices" that it has printed
a letter at the "end" of the line (letter_count % 80 == 0
) it need to print
out a new line character.
letter_count
is synchronized
.
extends Thread
first.
implements Runnable
synchronized
code in place.
![]() | ![]() | ![]() | 4.5 Week 5 - Threads |