Saturday, June 23, 2012

(Anything)^0 =1 .. How

How many of you asked this question to others or yourself . did u guys get the answer for this ?

well, Proof for this so simple ..

(Anything)^0  =1 

replace 0 by  1/(Infinity) ... we finished    ... for instance    (234)^ 0 = 1 .. check out below fig



(A+B)^2 = A^2 + B^2 + 2AB ???



Thread

Thread is most important concept in software development . It is very important to know about it .

What is Thread : Thread is separate execution of code 

one thing I wanted to tell ,Threads are EVIL ,don't create it until and unless an absolute necessary . 

Why (Advantage) Threads : To have concurrent execution of code .

Why not (Disadvantages) : 
  1. Thread introduces context switch ,which will slow down the application performance
  2. Need to use synchronization for the shared object  

yes , I hope you know , why Thread is having separate STACK and why it is sharing HEAP ...

anyways I'll be explaining this in my future blogs ... Keep reading ...
 



Active Scheduler in Symbian

We know, what is Active Scheduler and what is the role in symbian ...
Now ,I wanted to explain ,why we are creating Active Scheduler for all the thread , why can't we have only one Active Scheduler  for all the thread ..

Ok, I'll explain multithreading application with single Active scheduler, at the end  you will come to know where the problem starts and why we are creating Activescheduler per Thread.

Active Scheduler contains 2 Active object both are requested from each thread.

Now 
1. AO1 is running ,Thread1 cycle is completed before completing the RunL() of the AO1
2. Now , Thread2's time to execute , and AO2's request has completed .
3. since AO1 is not completed ,Active scheduler won't start AO2  execution

    see , here we are wasting Thread2's cycle . and AS wont start AO2 until and unless AO1 is completed.

In case , If we have AS per thread , then there is no wastage of cycle.

Hope now you understand why we need to create AS for each Thread.





Tuesday, June 19, 2012

Synchronous AsyncTask

In Android , there are some APIs (specially network related ) can called from another thread. and there will be some situation you will be encountered that , the main thread needs result of the Asynctask thread .

well , it is quite easy in android

you have to use below piece of code

             new TimerTask().execute().get();


timertask is extends from AsyncTask .

ie Thread1 will wait for thread2's result ..