I knew that System.out is buffered. It will not print the output to terminal until it is explicitly flushed or program is terminated.
I wrote below program to test my understanding. I was thinking that output of my program would be printed when the program terminates because i am not explicitly flushing the stream. But the output is getting printed as soon as print is executed and then program goes into 5 second sleep.
Could anyone please suggest the reason.
class PrintandSleep {
public static void main(String args[]) throws InterruptedException{
System.out.print("xyz");
Thread.sleep(5000);
}
}