Java concurrency package: Difference between revisions
imported>Prn Dan Mo No edit summary |
imported>Prn Dan Mo |
||
Line 12: | Line 12: | ||
thread can execute an object's synchronized methods at a time” and “also allows threads | thread can execute an object's synchronized methods at a time” and “also allows threads | ||
to wait for resources to become available, and allows the thread that makes resources | to wait for resources to become available, and allows the thread that makes resources | ||
available to notify other threads that are waiting for the resources” [ | available to notify other threads that are waiting for the resources”." | ||
<ref name="Java Synchronization"> | |||
{{cite web| | |||
http://www.d.umn.edu/~gshute/java/synchronization.html| | |||
title=Java Synchronization| | |||
last=Shute| | |||
first=Gary| | |||
publisher=[[http://download.oracle.com/]]| | |||
year=2010| | |||
accessdate=2010-08-12}} | |||
</ref>. When the | |||
synchronized keyword is used, the thread which invokes the synchronized method must obtain | synchronized keyword is used, the thread which invokes the synchronized method must obtain | ||
a lock for the object which makes this thread the lock holder. The rule of thumb of | a lock for the object which makes this thread the lock holder. The rule of thumb of | ||
synchronized method is that only one thread can hold this lock at a time. | synchronized method is that only one thread can hold this lock at a time. | ||
==Links== | ==Links== |
Revision as of 12:57, 12 August 2010
To provide students with experience in collaboration, you are warmly invited to join in here, or to leave comments on the discussion page. The anticipated date of course completion is 13 August 2010. One month after that date at the latest, this notice shall be removed. Besides, many other Citizendium articles welcome your collaboration! |
The Java concurrency package is a library supporting threading and parallel programming in the Java programming language.
Synchronizers
Mutilthread Synchronization before Java 5
Before Java 5, multithreads are supported using the lock mechanism for synchronization. Locks are implemented in Synchronized method. This mechanism “ensures that only one Java thread can execute an object's synchronized methods at a time” and “also allows threads to wait for resources to become available, and allows the thread that makes resources available to notify other threads that are waiting for the resources”." [1]. When the synchronized keyword is used, the thread which invokes the synchronized method must obtain a lock for the object which makes this thread the lock holder. The rule of thumb of synchronized method is that only one thread can hold this lock at a time.
Links
References
- ↑ Error on call to Template:cite web: Parameters url and title must be specifiedShute, Gary (2010). . [[1]]. Retrieved on 2010-08-12.