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)
?
I have checked the given link
As per the method signature it says println(String)
is synchronized and println(char[])
is not. However, when you read the description of println(char[])
it says it prints the string representation of the given char[]
ie it implicitly converts the given char[]
to String
and calls the println(String)
method.
So even though println(char[])
is not synchronized it achieves the synchronization implicitly by calling println(String)
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.