Samstag, 29. November 2008

EE3206/EE5805 Java thread-3

EE3206/EE5805 Java Programming and Applications

notes on 14.3 Synchronization, from "The Java Programming Language":

1. We need to avoid interleaved operation that can corrupt the data. Such potentially interleaving actions are termed critical sections or critical regions, and you prevent interference by sychronizing access to those critical regions.

2. It is solved by acquiring a lock on an objet. Threads cooperate by agreeing to the protocol that before certain actions can occur on an object, the lock of the object must be acquired.

3. Acquiring the lock on an object prevents any other thread from acquiring that lock until the holder of the lock receives it.

4. Every object has a lock associated with it, and that lock can be acquired and released through the use of synchronized methods and statements. The terms syschronized code describes any code that is inside a synchronized method and statement.



Keine Kommentare: