2008-08-02

Java thread safety: Memory Consistency Properties

From the words-to-live-by department (or, the java.util.concurrent javadoc):

Chapter 17 of the Java Language Specification defines the happens-before relation on memory operations such as reads and writes of shared variables. The results of a write by one thread are guaranteed to be visible to a read by another thread only if the write operation happens-before the read operation. The synchronized and volatile constructs, as well as the Thread.start() and Thread.join() methods, can form happens-before relationships. In particular:
  • Each action in a thread happens-before every action in that thread that comes later in the program's order.
  • An unlock (synchronized block or method exit) of a monitor happens-before every subsequent lock (synchronized block or method entry) of that same monitor. And because the happens-before relation is transitive, all actions of a thread prior to unlocking happen-before all actions subsequent to any thread locking that monitor.
  • A write to a volatile field happens-before every subsequent read of that same field. Writes and reads of volatile fields have similar memory consistency effects as entering and exiting monitors, but do not entail mutual exclusion locking.
  • A call to start on a thread happens-before any action in the started thread.
  • All actions in a thread happen-before any other thread successfully returns from a join on that thread.


The methods of all classes in java.util.concurrent and its subpackages extend these guarantees to higher-level synchronization. In particular:
  • Actions in a thread prior to placing an object into any concurrent collection happen-before actions subsequent to the access or removal of that element from the collection in another thread.
  • Actions in a thread prior to the submission of a Runnable to an Executor happen-before its execution begins. Similarly for Callables submitted to an ExecutorService.
  • Actions taken by the asynchronous computation represented by a Future happen-before actions subsequent to the retrieval of the result via Future.get() in another thread.
  • Actions prior to "releasing" synchronizer methods such as Lock.unlock, Semaphore.release, and CountDownLatch.countDown happen-before actions subsequent to a successful "acquiring" method such as Lock.lock, Semaphore.acquire, Condition.await, and CountDownLatch.await on the same synchronizer object in another thread.
  • For each pair of threads that successfully exchange objects via an Exchanger, actions prior to the exchange() in each thread happen-before those subsequent to the corresponding exchange() in another thread.
  • Actions prior to calling CyclicBarrier.await happen-before actions performed by the barrier action, and actions performed by the barrier action happen-before actions subsequent to a successful return from the corresponding await in other threads.

4 comments:

Anonymous said...

Keep up the good work.

Anonymous said...

отец доча порно
секс знакомства армавир
учебник виртуальному сексу
секс рассказы писька
бесплатный просмотр порно без смс
порнуха видео смотреть
порно мультяшки бесплатно
бемплатное порно
супер порно попки
toilet sex

Anonymous said...

Web hosting is a server for serving and maintaining files looking for in unison or more net sites.
A web hosting accommodation is a genus of Internet hosting overhaul that longing help an special, house, alma mater, administration organization and more vicinity their website on the In all respects Broad Web.
[url=http://www.jkahosting.com]Web hosting [/url] companies purvey space on a server someone is concerned take via their clients as grandly as the internet accessibility required to bag on the web.
Rounded off more powerful than the computer play is a sound environment in the course of the files and a fast bearing to the Internet.
There are various unique types of snare hosts, control panels, operating systems, and options.
In extension there are included services such as website builders, search appliance marketing, database deployment, and online stores.
So how do you grasp what to put into practice and who to take it from?
Since they are so tons options this can be confusing.
The prime thing you extremity to decide is if you hope for a Windows spider's web publican or a linux trap host.
Much of the time it does not matter though if you eat specific software to capitalize on such as a shopping transport or database bearing this force be important.
It is best to discover out cold from your software provider the requirements of the program.
Then you pleasure call to decide on if you demand a field name and the amount of latitude and bandwidth needed.
Various web hosting companies in actuality impart away domain names to unique customers so this may assist sway your business.
In addendum scads network hosts also issue a prodigious amount of space and bandwidth in their hosting plans hoping you desire not in fact need it.
So now that you be subjected to obvious on the operating pattern and how much you lack instant let us look at the options.
A deeply approved chance is the speak of a unfettered website builder. This can be critical if you get no or midget wisdom with html programming. If you have some participation and scorn a database you will then distress to conclude how varied databases you require. Some hosts inclination occasion you unlimited databases and some direct blame per database. There are also varied other freebies convenient such as automated script (software) installation, shopping carts, templates, search engine optimization benefit, unlimited domain hosting and much more. Spam taboo is also an important characteristic you should calculate from your host.
Now that you entertain found the options you are looking for it is time to look as regards a host.
Wow! There are so many. A elementary search in search the period of time network innkeeper last wishes as produce thousands of results. So who do you choose?
A web master should always be present in for fear that b if you need assistance. At the least they should have in the offing a support desk and faq square in case you secure questions. If possible a phone number is also helpful. They should also provide a abstention server so your website is instantly visible and not slow to view. In putting together they should plan for no or very bantam downtime. This is when your website is not clear at all. In the long run your files should be in a established environment. After all you do not want someone accessing your files or infecting your website with malware.
To conclude they are many trap hosting options and hosts. It is momentous to do your homework to bump into uncover the tucker a given pro your website.

Anonymous said...

Field Combat Medicine hot news
levitra price
Likewise, it has provided first-time success and reliable way of enhancing erection quality for many men, including those with high cholesterol, high blood pressure, or diabetes.
[url=http://www.troyconstructionservices.net/]buy levitra online[/url]
Neither will it provide you an instant erection; sexual excitement is requisite for it to work.
http://www.troyconstructionservices.net/ - cheap levitra
Once a man has completed sexual activity, blood flow to his penis should minimize and his erection should go away.


cheap propecia online
Buy generic Propecia online and save your money.
[url=http://www.ahpalphasigma.com/]propecia 5mg[/url]
Once DHT is out of the picture, it represents one key loss in the fight against you growing hair.
http://www.ahpalphasigma.com/ - propecia without prescription
This is the chemical that stops DHT from causing male pattern baldness.