Multithreading: Lecturer: Hồ Tiến Lâm
Multithreading: Lecturer: Hồ Tiến Lâm
Multithreading
Lecturer: Hồ Tiến Lâm
Contents
Threads Introduction
Interrupting Threads
Thread States
Thread Properties
Synchronization
Callables and Futures
WHY???
Thread 1 Thread 1
calls finish
transfer executing
Thread 2 Thread 2
calls proceed
transfer→
blocked
synchronized (obj) {
critical section
}
if (myLock.tryLock())
// now the thread owns the lock
try {...}
finally { myLock.unlock(); }
else
// do something else
myCondition.await(100,
TimeUnit.MILLISECONDS))