CSE 8B Lecture 14: More multi-threading/ Synchonization

64 views3 pages

Document Summary

Synchronization yield() let other threads run if there are threads running sleep() will not run at all for a certain amount of time join() waits for calling thread to die. I have two threads t1 and t2 t1. join() means that the main thread will stop running and wait for t1 thread to finish t2 thread is unaffected and is still running in parallel with t1. Runnable is the interface to implement for making a thread. Override run method called when you (cid:862)start(cid:863) a thread. Os decides which thread has priority over which leads to random threads running unpredictably. Single core: threads can be swapped out at any time. Called context switch: no way of knowing when this might happen. Multiple cores: each core gets temp copy, both could read array[0], but either could write over it. 2 threads with same code running in parallel for(int i = 0; i < 3; i++) {

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents