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 :-(


Abhishek said...

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

Vaibhav said...

Here is what said by Daniel:


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...


[b]Xrumer SEO Professionals

As Xrumer experts, we have been using [url=]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.

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.


Anonymous said...

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

Anonymous said...

Coincide Our Indelicate Prices at, The Important [b][url=]Online Pharmacy [/url][/b] To [url=]Buy Viagra[/url] Online ! You Can also Chance Colossal Deals When You [url=]Buy Cialis[/url] and When You You [url=]Buy Levitra[/url] Online. We Also Be subjected to a Staggering Generic [url=]Phentermine[/url] On account of Your Keep ! We Cry quits up Pre-eminence stigmatize [url=]Viagra[/url] and Also [url=]Generic Viagra[/url] !

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 as our default [url=]url shortener[/url], so every link will be there and visible for everyone.

You can choose from several great [url=]short url[/url] address like: and many others.

They have above 60 other available domains and the [url=]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=]url redirect[/url] service too!

Thank you.

Anonymous said...

I'm new around here, seems like a cool place though. I'll be around a bit, more of a lurker than a poster though :)
[url=]Acai Berry[/url]
Acai Berries
Acai Berry
Acai Berry

Anonymous said...

[b]Website Traffic[/b]

A new way to get traffic to your website. Not only will you get loads of [url=]traffic[/url] more and more everyday you will also get backlinks with all the other sites on the [url=]grid[/url] getting you a better search engine ranking which will get you even more [url=]website traffic[/url].Get on the pixel grid today and let the traffic come to you.Taking the internet by storm.The new way to advertise.


Anonymous said...

Hi Guys,Just registered here and looking to have a great time. I am looking for the best cash fiting program out there in the internet. Can you guide me?

Below are some sites that I found and I am not sure how much they are going to help me.
[url=]cash gifting[/url]
[url=]join cash gifting[/url]
[url=]best cash gifting program[/url]

Anonymous said...

Making money on the internet is easy in the undercover world of [URL=]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=]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=]casino[/url] refer to and acquiesce up online casino games like slots, blackjack, roulette, baccarat and more at .
you can also clinch our latest [url=]casino[/url] direction at and boss documents wearisome dough !
another boaster [url=]casino spiele[/url] federated with is , in the procedure of german gamblers, carry well-wishing online casino bonus.

Anonymous said...

Anonymous said...

[url=]Porn video online[/url]
[url=]Porn video download[/url]
[url=]Porn video torrent[/url]
[url=]Gay porn online[/url]
[url=]Teen porn online[/url]
[url=]Free porn videos online[/url]
[url=]Best porn video[/url]