Does anybody know why the member call println of PrintStream is synchronized?
For example: public synchronized void println (String str)
But why there is no synchronized for public void println (char[] chars)
?
Does anybody know why the member call println of PrintStream is synchronized?
For example: public synchronized void println (String str)
But why there is no synchronized for public void println (char[] chars)
?
Copyright © 2021 Jogjafile Inc.
I have checked the given link
As per the method signature it says
println(String)
is synchronized andprintln(char[])
is not. However, when you read the description ofprintln(char[])
it says it prints the string representation of the givenchar[]
i.e. it implicitly converts the givenchar[]
toString
and calls theprintln(String)
method.So even though
println(char[])
is not synchronized it achieves the synchronization implicitly by callingprintln(String)
.