CSCI 201 Study Guide - Final Guide: Thread Safety, Thread Pool, Race Condition

79 views5 pages

Document Summary

Synchronization motivation = to coordinate the execution of dependent threads, to control which threads execute or what goes on simultaneously. Race condition = a state where more than one thread is accessing the same variable and overwriting the other thread"s updates. Thread-safe = if an object of the class does not cause a race condition in the presence of multiple threads. Critical section/ region = section of code that needs to avoid race conditions. Is an object with mutual exclusion and synchronization capabilities (all objects in java can be!) synchronized keyword enables the use of monitors. Thread enters a monitor by acquiring a lock on it and exits by releasing the lock. wait() inside a monitor releases a lock, needs to be awakened with notify() or notifyall() Object on with the method was invoked gets the lock. Lock is acquired, then the method is executed, then the lock is released.

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

Related Documents