I think it is only a 4 digit integer number that i am sending, Well here is the code,
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', <CR>, <LN> to the serial port.
You are then reading one character at a time, '8', '7', '3', <CR>, and <LF>, 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 <CR>, 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 (<CR>). Then, int() will convert that string to an int.