LED flash realtime as processing told

i try to let an led analog flash as processing told from serial. but it looks like not realtime , i don't know how.
processing just write serial a 0-254 number and a '\n' ;
Arduino code is :

String sread;
int Bpin = 11;

void setup() {
  Serial.begin(57600);
}

void loop() {
  while (Serial.available() > 0) {
    sread = Serial.readStringUntil('\n');
    if (sread != "") {
      analogWrite(Bpin, sread.toInt());
    }
  }
}

What does happen when you run the program and send a number ?
What do you see if you print sread ?
How long do you expect the LED to stay on ?

UKHeliBob:
What does happen when you run the program and send a number ?
What do you see if you print sread ?
How long do you expect the LED to stay on ?

if i send a number manually to the Arduino board it just change the led brightness with a delay.
i can't open the serial windows open while the processing is sending the serial to arduino board.
i was trying to sample a B/W photo pixel from processing , and what the led flash realtime as the brightness sample of processing...it is not a quick movement in processing ,almost one second a pixel .

i can't open the serial windows open while the processing is sending the serial to arduino board.

You could use SoftwareSerial to communicate with Processing or an external terminal emulator to monitor the value(s)

and what the led flash realtime as the brightness sample of processing

What will make the LED flash as opposed to just changing its brightness ?

You could use SoftwareSerial to communicate with Processing

No, you can't.

Processing IS capable of reading the serial port, though, so it can perform all the same functions as the Serial Monitor application.

The underlying assumption in OPs post is that the Arduino and/or its code must be at fault. More than likely, it is that Processing and the Arduino are not speaking a common language. Without seeing the Processing code, any suggestions on how to fix the Arduino code are pointless.

You could use SoftwareSerial to communicate with Processing
No, you can't.

Processing IS capable of reading the serial port, though, so it can perform all the same functions as the Serial Monitor application.

Is it not true that SoftwareSerial can write to a serial port on a PC (albeit via a level shifter) and Processing can read from a serial port on a PC ?

Is it not true that SoftwareSerial can write to a serial port on a PC

If you have an ancient PC that still has a real 9 pin serial port - typically only seen in museums these days.