Friday 21 August 2015

What is happening !!

I was born and brought up in a small town, with friends and relatives in every lane. Parties always happened at home, we didn't have culture to go to restaurants for food. Life was too simple. Infrastructure and medical facilities were very minimal. Family income was also limited. There was only one park in the town. When water logged on streets during rainy season, we used to make paper boats and sail them in the water. Once, the high school boys and some of our neighbors even took a boat into the paddy fields in our water logged farms and they enjoyed sailing there, as if in a massive river. When strikes happened, we were happy about the unexpected school vacation. Once, there was no electricity for almost a month in our colony because the transformer had burnt down, can't even imagine how we survived, but can't recall any uncomfort as well - that we might have experienced in that period. We ate fresh fruits and vegetables straight from the market, power cut was a frequent routine and in sweaty summer days, we used to head to our roofs where we would camp out at night in the cool breeze, and compete in counting the stars with a dozen cousins - and have a nice peaceful sleep gazing at them. 

Life has come a long way. I live in a big city now and earn much more than what my entire family managed to ,put together. We have power backup, continuous water supply, and all other material comforts that count in life. But at times, I feel more stressed and unhappy than ever before. I don't get to see the starts - because I don't have time to , the sky is full of dust and there is no roof to lie down on. The lanes are not water logged, but they are traffic clogged. There is no fresh air, fresh fruits and fresh vegetables right from the backyard garden. Many relatives are there - but there is no time to meet. Parties happen at restaurants and its more of a showoff of money than real pleasure. People who counted in life got scattered - some left behind, some moved ahead, some are near and some far - but the dynamics have changed so much.

Sometimes I get to seriously wonder if this is the life we had all carved for. If we had remained in that small town for the better, if we had changed it for the better, if we could have harmonized the natural surrounding of our birth place with better modern facilities that we all carve for - it would have been what we all imagine as 'heaven'. Will I get that heaven in this lifetime? Sounds ironical - don't we have to die to be in heaven? But is this life in any form better than being dead...... and we live on!!! :)

Sunday 2 August 2015

Served with a baee ultimatum

I don't even need to mention how important a role kaam wali baee or a maid servant plays in the life of an Indian woman. Its easy to manage without the husband for few days but without a baee...even a single day is impossible! Life comes to a standstill without her. Nevertheless, even madame baee very well understands her importance in our lives and when people with little minds and big arrogance feel they are important for some reason, the arrogance reaches cloud 9. The same has happened off late with my baee.

I still remember the 'one fine day' when we moved into this apartment. While i was still settling down & unpacking things, bang on the door she was! GOD knows how she sniffed the new comers in the new flat and came looking for the job. But I was more than happy to have got a maid without getting to hunt for one. Another 5 minutes with her and I realized that if this lady was going to work for me, I had to put up with few things like her constant meaningless chatter , her arrogance and I had to bear in mind that she was going to be the boss. Still,overwhelmed with the feeling of getting a baee so easily, i put her on my payroll and happily closed the chapter with a 'feeling blessed' status for rest of the day.

Comes the next day and she says, "itne paise me itta nahi hoga didi. bagal ke ghar me to double offer kar rahe hain(i can't do all that you want in this much money, the flat next door is offering me double the amount)". All my dreams seemed to be shattered in a moment. But through all the harshness of my capricornian life, one thing that I have resolved for is not to give up easily. I told her she could leave because I was offering her the best I could, and right upfront I announced to her that even in case I was not going to get another maid, i will do all the work myself, as i knew very well that the next thing she would do was to scare me off with the threatening to not allow any other maid to enter my premises (although I only know how scared i was inside!!!). To my relief, she decided to continue.That was followed by a series of crockery shattering, broom breaking etc. which I don't want to cover here (I just realized i actually have enough material for a novel!)

Now an year has passed, and things have been moving smoothly, of course on the cost of few adjustments, like, she comes on her own time and leaves on her own time - we dare not ask any questions about that. She rarely comes on sundays, if she really feels to shower us with her blessings, she will show up on some sundays. we are not supposed to mention it as its her unofficial holiday. she demands a new broom and floor cleaner every month, and a new soap bar every third day - no questions to be asked. If a guest arrives - she asks us a million questions like how many, for how long, etc. etc. and we comply. She can be on leave of absence anytime and anyday without prior notice and the number of days are not fixed. We dare not cut her pay or ask her harshly about it. Then there are days when the boss doesn't seem to be in such a good mood when she arrives at work - ofcourse her domestic life is also full of the general domestic problems that each one of us faces and that grows at times out of proportion - so she can't be blamed for the bad mood, and then who else will she get to unleash her frustration on than us the poor beings, and our utensils. God, you should see the beating she gives to the utensils the day her mood is bad!! At times, in my imagination, she is like that wicked witch with a broom who can curse us to hell anytime she decides to board her broom and fly out of the window while we watch helplessly.

But then yesterday my mom voilated one of the treaties. I can't completely blame her, afterall she is also human and most of the days she is the one dealing with the boss and facing the heat.

So it all started with the maid showing up early that day, when mom asked her why her timings were so irregular. Ofcourse madame baee was offended. She said (with this hidden warning) that there were timing conflicts happening and she had to quit from one or the other house work by the end of the month. Now it was mom's turn to get offended and the war of words started. I was happily working in office , unaware of the great turmoil at home. As soon as I came back and stepped in, mom unleashed her dissatisfaction about the maid. Now, it was my turn to take sides, control the situation, and discuss with mom on what to do.This is not the first time such a situation had arrived, but the irony of the situation struck me fully yesterday. 

After a 1 hour discussion with mom finally the conclusion was to continue with her as the pain of getting a new maid and ensuring she was as good as the current one, seemed to overshadow the pain of dealing with the current one!!! What if the other maid that comes takes even more leaves, she is not honest and steals things, she asks for advance money now and then. At least the current one doesn't do all this! Obviously, We are the human race who is always afraid of changes and to explore the unknown, and on top of that we are middle class service oriented private servants ourselves, so, we are used to these nagging from bosses. So, finally we also shed our frustration by talking and discussing things for couple of hours and then got back to our normal lives! The day crisis strikes and boss quits, I will muster some courage, take control of my sinking domestic life ship and hire another commander for it..till then I should perhaps just chill!!!!

Tech Talk... Java fork/join pool

What is Java fork/join pool?
There are situations when there are multiple processors that an application can leverage on to increase its computational efficiency. How the application can do this, is generally, by breaking a big chunk of work that it might be serially doing, into subtasks which can then be divided among the different processors available, which can do the processing in parallel. The java fork/join pool provides a framework to achieve exactly the same. It wraps the complexity of thread creation, pool management and getting the work done in parallel, leaving to the user the only responsibility of his core computation logic and splitting the work when desired.
How to use Java fork/pool?
Simple, need to extend a ForkJoinTask (or its subclass RecursiveAction) and then assign it to a ForkJoinPool which will get it executed. The pool executes the task and on completion, returns back the control to the invoker thread.
The Fork/Join concept it recursion based, so, the ForkJoinTask invokes its instances recursively until the work is broken into the desired level of chunks and then is executed. The invocation through invokeAll method insures that all the tasks will be completed in parallel and then the control will be returned back to the caller, so, it would appear to the caller as if the tasks were done in a blocking fashion.
Sample program
Below is a sample program that shows the use of fork/join. The execution that the program needs to do is simple - print elements of an array list, along with the name of thread that is printing it. But, the elements need not be printed in order, whenever the size of the array list is greater than a threshold, subparts of this array list are recursively handed over to further instances of the ForkJoinTask which get it executed in parallel. The parallel execution can be observed by running the task multiple times and seeing that the sub-array-lists are executed in alternate orders at time and the order keeps changing every time the program is executed.
So, below are the steps for writing a program to use the fork/join framework:
Step1: Subclass the ForkJoinTask class and have your implementation inside it:
public class ForkJoinExample extends RecursiveAction {
       //An array list that would hold the numbers to be printed
private ArrayList<Integer> events;
       //if the number of elements in the array list is > this threshold, divide the task
private int computationThreshold;
       //name of the class, when printed, can help identify how the parallel execution is happening
private String name;
       //counter for appending to the name of the class
private static int count=0;

public ForkJoinExample(ArrayList<Integer> events, int computationThreshold,
String name) {
this.events = events;
this.computationThreshold = computationThreshold;
this.name = name;
}

//this method is supposed to be invoked for direct computation once the work has been broken down to the desired extent
private void computeDirect(){
for(int i=0;i<events.size();i++){
System.out.println("Printing from :" + name + ":  " +events.get(i));
}
}

//this is the method that would be invoked by the ForkJoinPool
//Inside this method, the work can be further subdivided recursively
@Override
protected void compute() {
//if the threshold value is not reached, direct computing can be done
if(events.size() <= computationThreshold){
computeDirect();
return;
}else{
//break the task among threads and let each one do the computation of its own
int split = events.size()/2;
ArrayList<Integer>firstHalf = new ArrayList<Integer>();
ArrayList<Integer>secondHalf = new ArrayList<Integer>();
for(int i : events){
if(i>split){
secondHalf.add(i);
}else{
firstHalf.add(i);
}
}
invokeAll(new ForkJoinExample(firstHalf, computationThreshold, this.name+(++count)),
new ForkJoinExample(secondHalf, computationThreshold, this.name+(++count)));
}
}
}
Step 2: Create a ForkJoinPool and let it invoke the ForkJoinTask:
ForkJoinExample forkJoinExample = new ForkJoinExample(
new ArrayList<Integer>(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8)), 4, "Thread");
ForkJoinPool pool = new ForkJoinPool();
pool.invoke(forkJoinExample);

Sample outputs on running this program:

Output Sample 1:
Printing from :Thread1:  1
Printing from :Thread1:  2
Printing from :Thread1:  3
Printing from :Thread1:  4
Printing from :Thread2:  5
Printing from :Thread2:  6
Printing from :Thread2:  7
Printing from :Thread2:  8

Output Sample 2:
Printing from :Thread1:  1
Printing from :Thread2:  5

Printing from :Thread1:  2
Printing from :Thread2:  6
Printing from :Thread1:  3
Printing from :Thread2:  7
Printing from :Thread1:  4
Printing from :Thread2:  8