22-10-2016, 10:32 AM
1460445273-04Threads.ppt (Size: 432.5 KB / Downloads: 280)
– Threads allow the program to run tasks in parallel– In many cases threads need to be synchronized, that is, be kept not to handle the same data in memory concurrently– There are cases in which a thread needs to wait for another thread before proceeding
Synchronization of threads is needed for in order to control threads coordination, mainly in order to prevent simultaneous operations on dataFor simple synchronization Java provides the synchronized keywordFor more sophisticated locking mechanisms, starting from Java 5, the package java.concurrent.locks provides additional locking options, see: