I think it is only a 4 digit integer number that i am sending, Well here is the code,
Serial.println(elapsedTime);
The print()/println() methods convert the value to a string. Suppose that millis() returns a value of 873. You are then sending '8', '7', '3', , to the serial port.
You are then reading one character at a time, '8', '7', '3', , and , and assuming that you are getting an integer value ('8' != 8), which is not the case.
The Serial class in Processing has a bufferUntil() method, where you can tell Processing to call serialEvent() only when the , for instance, arrives.
In the serialEvent() method, you can then use the readUntil() method to get all the data (as a string) that has arrived ("873") up to the specified character (). Then, int() will convert that string to an int.