Wednesday, August 8, 2007

Could Madhani’s release impact Kerala Politics???

On February 14, 1998, shortly before BJP leader L.K Advani 's poll meeting, a serial blast rocked Coimbatore. Fifty-eight people were killed and more than 250 were injured. Nine years later, when verdict in the case was delivered on August 1, the reactions were mixed. Peoples of Democratic Party chief Abdul Nasser Madhani's family and followers are happy. Madhani was acquitted along with seven others, while al-Umma founder S.A Basha and 152 ohters were found guilty of conspiracy.Madhani's home-coming is expected to change the profile of minority politics in Kerala. The LDF government headed by E.K Nayanar projected Madhani's arrest as acheivement. Though the ruling UDF passed a resolution in March 2005 seeking Madhani's release, an angry PDP allied with the LDF to help its return to power last years. However he said in his Kairali channel interview that PDP would work for social revolution and party derived strength from all backward sections, including the Dalits. Whatever may be the declaration, one thing is sure that return of Madhani will put Muslim League on backfoot. In his speech at Thiruvanadapuram on day after his release was flooded with his supporters. From his speech we can conclude that as of now PDP will continue its alliance with LDF.

Tuesday, August 7, 2007

Multithreaded programming in JAVA

Last days I spend a few time for understanding multithreaded programming in JAVA. In C language it is done by including the header file pthread.h and the function pthread_create use for creating a new thread.

All modern operating systems support multitasking. However there are two distinct type of multitasking: process based and thread based. In thread based multitasking environment, the thread is the smallest unit of dispatch able code. This means a single program can perform two or more tasks simultaneously.

Creating a thread in JAVA:
Java defines two ways in which this can be accomplished.

1. implement the Runnable interface
2. extend the Thread class itself

Implementing Runnable
The easiest way to create a thread is to create a class that implements the Runnable interface. Runnable abstracts a unit of executable code. To implement Runnable, a class need only implement a single method called run().

After implements Runnable, instantiate an object of type Thread from within that class. Thread defines several constructors. The that we will use

Thread (Runnable threadOb, String ThreadName)

After the new thread is created, it will not start running until we call its start()

class NewThread implements Runnable {
Thread t;

NewThread() {
t = new thread(this,”demo thread”);
System.out.println(“child thread: “ + t);
t.start();
}


public void run() {
try {
for(int i=5; i >0; i - -){
System.out.println(“child thread” + i);
Thread.sleep(500);
}
}catch(InterruptedException e){
System.out.println(“Child interrupted “);
}
System.out.println(“child exiting normally”);
}
}

class ThreadDemo {
public static void main(String args[]){
new NewThread();
try{
for(int i=5; i >0; i - -){
System.out.println(“Main thread”);
Thread.sleep(1000);
}
}catch(InterruptedException e){
System.out.println("Main thread interrupted");
}
System.out.println("main thread Exiting");
}
}

In this program main thread and child thread will count five to one downwords simultaneously. But execution of main thread will be completed only after completing child thread execution.Because of the thread delay given in for-loops. Main Thread finishes last, because the main thread sleeps for 1000ms, but child thread only for 500ms. In fact some older JVMs, if the main thread finishes before child thread completed, then the java run time system may “ hang”. In above program it is done by sleep. However it is hardly a satisfactory solution.
There are two ways to determine , whether a thread finished . First, call isAlive() on the thread. The isAlive() method returns true if the thre upon which it is called is still running. It returns false otherwise.
class NewThread implements Runnable {
Thread t;
String name;

NewThread(String threadName){
name = threadName;
t = new Thread(this, name);
System.out.println("newthread:" + t);
t.start();
}

public void run(){
try{
for(int i=5; i > 0; i--){
System.out.println(name +":" + i);
Thread.sleep(1000);
}
}catch(InterruptedException e){
System.out.println(name + "interrupted");
}
System.out.println(name +"exiting normally");
}

}
class Demojoin{
public static void main(String args[]){
NewThread ob1 = new NewThread("One");
NewThread ob2 = new NewThread("two");

System.out.println("thread one is alive" + ob1.t.isAlive());
System.out.println("thread two is alive" + ob2.t.isAlive());

try{
System.out.println("waiting for thread to finish");
ob1.t.join();
ob2.t.join();

}catch(InterruptedException e){
System.out.println("main thread interrupted");
}

System.out.println("thread one is alive" + ob1.t.isAlive());
System.out.println("thread two is alive" + ob2.t.isAlive());

System.out.println("main thread exiting");
}
}

In output of this program ob1.t.isAlive and ob2.t.isAlive are true at first call, since threads are running at that time. ob1.t.join and ob2.t.join will wait for the child thread to complete execution.Second call of ob1.t.isAlive and ob2.t.isAlive returns false,since child threads completed their execution.

Friday, August 3, 2007

A mystery man came to play in kerala politics

Last week kairali channel went for Farris Aboobecker who donated 60 lakh Rs for E.K Nayanar memorial foot ball play and who gave 1 crore Rs for P.T Usha 's sports school. Everybody thought that he might be an old person.But when I saw him in front of John Brittas (Kairali channel MD) , I surprised, I understood Farris is a young , handsome man. In this story , interesting thing is , Kairali channel is CPI(M) party channel.Why did this party channel take interest in this mystery man??......He was sending arrows against CM of Kerala in his first and second interview. At the same time he refused or intentianally go backward when Brittas asking him about his background and asset . But at present present one this is clear, he is main share holder of Deepika news paper.....This mystery man proved that he could play lot off politrics in kerala.....