Randomness at its best

Journey from a no one to a someone

Sunday, November 18, 2007

Om Shanti Om

Oh I so much loved the movie... Loved everything including the curvy font in which the title of the film is written, the costumes, the songs. Shah Rukh Khan is still undisputed king of bollywood. His 6 packs abs... simply killing! Deepika Padukone is cute. And man... Farah Khan knows how to show off her power in film industry.

All in all... a hindi masala movie always makes moi happy.

Labels:

Wednesday, November 14, 2007

Gone... With The Smoke

Well... Yet another diwali has come and gone, without much glitter. I remember, when I was small, diwali was all about lights, crackers, gifts, sweets, new clothes. We used to get up in the morning, burst crackers, greet friends & family, jump n dance around. Basically have fun. Everything used to be so exciting. Its not the same anymore. Somehow the freshness is gone. People are not bothered. Frankly, I am not bothered. Its something I used to do when I was 5, why should I continue the same till I am 50. I guess my "Geminian " instincts are talking here. But I just don't feel like doing the same thing year after year.

Why should things have to be done in a conventional well defined manner. We got to bring about a change. If we continue to do the same thing that our ancestors have been doing for ages, where is the new generation, new thinking, new way of life? Well... I am not saying everything needs to be revamped, I still feel my kids should celebrate diwali the way I did when I was a kid. Its fun that way. I have never regretted the way I have been brought up. But now, theres got to something different. Different in what way, I don't know. I am still trying to figure out.

I don't even know what I am thinking or what I am trying to get at. I guess festivals are not about lightings and glitter, its about memories, a way of holding on to things that you love, things that you are and things that you wish you will never lose. The world is moving too fast and everyone is losing out in the rat race of weekly milestones, monthly EMIs and annual dividends. So the best we can do is be happy about whatever little we have and wish that everyone gets their share of happiness.

Labels:

Monday, November 5, 2007

Unlocking the Double Checked Locking

In my career of about 1 year in IT industry, I have faced almost all instances of double checked locking failing in case of singleton. Frankly, this is a good problem to have when you know what what is causing the problem and what is the solution... Well, until, your solutions start failing too. Here is my account on what can make singleton create multiple instances.

1) One can serialize a singleton just like any other object. But when you deserialize it, you will get a new instance of class every time because the reference to that object is null. There is a readResolve() method in dateFormat to get around this problem.

2) If your singleton class extends another class that supports cloning, your class also will be clonable.
SingletonObject clone = (SingletonObject) obj.clone();
In order to avoid this, add a clone method of your own in your singleton which throws an exception say cloneNotSupportedException().

3) There can be more than one instances of singleton if you use lazy initialization(neglecting synchroniztion). One should always use double checked locking along with a volatile boolean in order to avoid optimization done by compiler.

4) Multiple singltons might occur if someone subclasses your singleton. In this case if you have made constructor of your singleton protected, the sublclass might expose it making its constructor public. As instance of subclass is an instance of superclass, you will have multiple instances of singleton. To avoid this, always make constructor of singleton private.

5) When inside the constructor, a thread might take considerable amount of time to create an instance, by which time another thread might come, see a non-null instance and proceed with the half created instance. Another flag might come in handy here which you can set to true once the instance has been created. This boolean will be checked along with the null==instance condition.

Well... these are all I have come across so far. If you really don't want to get in this mess and simply don't care about the whole performance bit, simply synchronize getInstance() and you shall achieve what is intended.

Labels:

Friday, November 2, 2007

A Constitution Called Marriage

As a part of "society" there are some funny rituals we have to follow. It always amazed me how can two people who have never seen or heard of each other, decide to spend their whole life together, in course of a couple of meetings between their folks and whatever 10 mins they are allowed to spend alone together. I always used to think that there are certain things that will never ever happen to me. Slowly but surely I see them happening though.

I got a couple of "proposals" few days back. Really strange to see guys lined up like that on paper. DOB-XXX, Cast-XXX, Height-XXX, Education-XXX. How can anyone put themselves like this and expect another individual like them based on that. Having said that, I know that I am pretty much available as a bunch of specifications on some paper. And if I manage to impress someone with that, they will ask for my photo. Eventually, there will be remarks like hair too short, I don't like her smile, nah... too thin, too dark. So basically, I, a human being capable of having emotions, will be treated as a commodity in market. And there will be yet another victim of a constitution called marriage.

Labels: