COMP 409 Lecture 4: Lecture4 2018
Document Summary
Subtlety: program exits when all non-daemon threads finish, daemon threads terminate automatically when all non-daemons are done. (default) non-daemon threads. Java"s model: priority-based, nominative priority-preemptive model (does not 100% guarantee how it is supposed to work. High a b c j. Low g h i d e f. 17: threads at the highest level execute in preference, 3 cpu"s: a, b, c. If we had more, we round-robin time slices. It will get woken up after at least [time] ms: yield(, give up a time slice (hit) while(true) { yield(); Thread. currentthread(); isalive(: true if thread can be scheduled, myself true, someone else, stale info, wasalive() , stop() (deprecated, asynchronous termination bad, dangerous, system in inconsistent state, destroy() (deprecated, asynchronous termination bad! join(, t1. T2. join() wait until t2 is finished: waits for a thread to finish. Basic synchronization: every object has a lock, only 1 thread can acquire a lock at a time a lower bound on sleep time.