Sunday, April 27, 2008

Atomic Operations in Java

Knowing atomic operation is very important when we are writing thread operation. Covering atomic operation inside synchronized keyword is just a overhead which we discussed sometime back in one post. Now

what all comes under atomic operation:

1. a = a + 1 - certainly not. Because this operation can use a local variable or a register to store the information before assigning it back to a. This operation is more or less like:

temp = a+1;
a = temp;

Certainly, reading value of a in between the two operation will create a dirty read.

2. a = b; Is this a atomic operation ? It depends ! Java Specification says that assignment to variables smaller than or equal to 32 bits is an atomic operation, which excludes variables of types double and long

(both are 64 bits). So, the operation is atomic or not completely depends on type of a and b. Now, reason behind such a specification is very clear, any operation more than 32 bit should need a extra

storage(basically register) for a 32 bit processor. But here Java Spec is not speaking about any processor dependency. Now, I am surprised how VM will handle atomicity if ran on 16 bit processor. I don't know

but I guess we can run JVM on 16 bit processor. Is it handles atomicity internally ? How about 64 bit processor. Even double and long operation should be atomic.

I am confused :-(

10 comments:

Waterfox said...

This is a nice doubt. But depending on the concept I guess you can assume whether operation will be atomic or not.

Vaibhav Choudhary said...

Here is what said by Daniel:

Comments:

If your 16-bit CPU support multi processor and incoherence cache, a correct implementation on 16-bit CPU require locking. All of the 16-bit CPU i am aware of use green thread and no extra processor, which need no extra protection.

Posted by Daniel on April 27, 2008 at 09:27 PM IST #

Anonymous said...

[u][b]Xrumer[/b][/u]

[b]Xrumer SEO Professionals

As Xrumer experts, we have been using [url=http://www.xrumer-seo.com]Xrumer[/url] for the benefit of a sustained immediately now and know how to harness the massive power of Xrumer and turn it into a Banknotes machine.

We also provide the cheapest prices on the market. Assorted competitors devise order 2x or square 3x and a destiny of the time 5x what we debt you. But we feel in providing gigantic service at a debilitated affordable rate. The large point of purchasing Xrumer blasts is because it is a cheaper alternative to buying Xrumer. So we train to stifle that thought in rebuke and provide you with the cheapest censure possible.

Not just do we cause the most successfully prices but our turnaround occasion for your Xrumer posting is super fast. We will pull someone's leg your posting done in the forefront you discern it.

We also cater you with a sated log of successful posts on contrary forums. So that you can catch a glimpse of over the extent of yourself the power of Xrumer and how we be struck by harnessed it to gain your site.[/b]


[b]Search Engine Optimization

Using Xrumer you can wish to see thousands upon thousands of backlinks over the extent of your site. Scads of the forums that your Place you intent be posted on oblige great PageRank. Having your tie-in on these sites can deep down serve establish up some top-grade rank help links and as a matter of fact boost your Alexa Rating and Google PageRank rating via the roof.

This is making your instal more and more popular. And with this better in celebrity as familiarly as PageRank you can envisage to witness your site really superiority high in those Search Locomotive Results.
Traffic

The amount of transportation that can be obtained aside harnessing the power of Xrumer is enormous. You are publishing your plat to tens of thousands of forums. With our higher packages you may regular be publishing your position to HUNDREDS of THOUSANDS of forums. Imagine 1 collection on a stylish forum drive usually enter 1000 or so views, with signify 100 of those people visiting your site. Modern assume tens of thousands of posts on fashionable forums all getting 1000 views each. Your traffic will withdraw because of the roof.

These are all targeted visitors that are interested or bizarre far your site. Assume how assorted sales or leads you can succeed in with this colossal number of targeted visitors. You are line for line stumbling upon a goldmine ready to be picked and profited from.

Reminisce over, Traffic is Money.
[/b]

TRAVERSE B RECOVER YOUR CHEAPLY ERUPTION TODAY:


http://www.xrumer-seo.com

Anonymous said...

Consent to to pass the mammal with two backs casinos? look into this advanced [url=http://www.realcazinoz.com]casino[/url] advisor and dally online casino games like slots, blackjack, roulette, baccarat and more at www.realcazinoz.com .
you can also into our unusual [url=http://freecasinogames2010.webs.com]casino[/url] leadership at http://freecasinogames2010.webs.com and prevail over authentic incredibly incorrect !
another late-model [url=http://www.ttittancasino.com]casino spiele[/url] concatenation of events is www.ttittancasino.com , in compensation german gamblers, come disentangle online casino bonus.

Anonymous said...

Nice brief and this post helped me alot in my college assignement. Thank you seeking your information.

Anonymous said...

Someone deleted several links from quickfiles and megaupload servers.

From now, we will use www.tinyurlalternative.com as our default [url=http://www.tinyurlalternative.com]url shortener[/url], so every link will be there and visible for everyone.

You can choose from several great [url=http://kfc.ms]short url[/url] address like:

kfc.ms easysharelink.info jumpme.info megauploadlink.info megavideolink.info mygamelink.info myrapidsharelink.info mytorrentlink.info myurlshortener.com mywarezlink.info urlredirect.info urlshrinker.info weblinkshortener.com youtubelink.info and many others.

They have above 60 other available domains and the [url=http://myurlshortener.com]url shortener[/url] service work well for free without any registration needed.

So we think it is good idea and propose you to use [url=http://urlredirect.info]url redirect[/url] service too!

Thank you.

Anonymous said...

Making money on the internet is easy in the undercover world of [URL=http://www.www.blackhatmoneymaker.com]blackhat software[/URL], It's not a big surprise if you have no clue about blackhat marketing. Blackhat marketing uses alternative or misunderstood ways to produce an income online.

Anonymous said...

You could easily be making money online in the underground world of [URL=http://www.www.blackhatmoneymaker.com]blackhat cpa[/URL], You are far from alone if you have no clue about blackhat marketing. Blackhat marketing uses little-known or misunderstood methods to produce an income online.

Anonymous said...

Infatuation casinos? enquiry this youngster [url=http://www.realcazinoz.com]casino[/url] refer to and acquiesce up online casino games like slots, blackjack, roulette, baccarat and more at www.realcazinoz.com .
you can also clinch our latest [url=http://freecasinogames2010.webs.com]casino[/url] direction at http://freecasinogames2010.webs.com and boss documents wearisome dough !
another boaster [url=http://www.ttittancasino.com]casino spiele[/url] federated with is www.ttittancasino.com , in the procedure of german gamblers, carry well-wishing online casino bonus.

Anonymous said...

http://www.pornvideoonline.info

http://www.pornvideodownload.info

www.pornvideotorrent.info

http://www.gaypornonline.info

http://www.teenpornonline.info

http://www.freepornvideosonline.info

www.bestpornvideo.info

[url=http://www.pornvideoonline.info]Porn video online[/url]
[url=http://www.pornvideodownload.info]Porn video download[/url]
[url=http://www.pornvideotorrent.info]Porn video torrent[/url]
[url=http://www.gaypornonline.info]Gay porn online[/url]
[url=http://www.teenpornonline.info]Teen porn online[/url]
[url=http://www.freepornvideosonline.info]Free porn videos online[/url]
[url=http://www.bestpornvideo.info]Best porn video[/url]