Académique Documents
Professionnel Documents
Culture Documents
Multitasking in Java
Threads in Java
Thread
Runnable
new(runnable)
start()
run()
Runs in a new
control flow
Returns immediately
Thread is finished
doTheStuff()
A word on
synchronization
Synchronized block/method
synchronize {}
// sync. on this
synchronize(obj) {}// sync. on obj.
A word on blocking
Wait for
target
Sleeping
Running
wait()
notify() /
notifyAll()
join()
Not
interrupted
New
start()
interrupt()
Target finish
sleep()
Time out
Interrupted
Dead
interrupt()
run() returns
Swing and
threads
Multitasking in GUI
applications
Swings threads
Executing events
Events
dispatcher
Event
handler
Interruptenqueue(event)
Interruptenqueue(event)
dequeue()
event
handle(event)
dequeue()
event
handle(event)
Event
handler
handle(event)
Worker
thread
start()
doTheStuff()
Thread is finished
Problems with
multithreaded GUI
Swing timers
Performing queued
works
Swing
Utilities
inovkeLater()
Events
queue
Events
dispatcher Runnable
enqueue()
Later, when
there are
no events
dequeue()
runnable
run()
Update
things