提交 ceb4675a 编写于 作者: J jlaskey

8015727: Thread safe print function

Reviewed-by: sundar
Contributed-by: james.laskey@oracle.com
上级 c5a32e42
......@@ -1628,20 +1628,21 @@ public final class Global extends ScriptObject implements GlobalObject, Scope {
@SuppressWarnings("resource")
private static Object printImpl(final boolean newLine, final Object... objects) {
final PrintWriter out = Global.getEnv().getOut();
final StringBuilder sb = new StringBuilder();
boolean first = true;
for (final Object object : objects) {
if (first) {
first = false;
} else {
out.print(' ');
if (sb.length() != 0) {
sb.append(' ');
}
out.print(JSType.toString(object));
sb.append(JSType.toString(object));
}
// Print all at once to ensure thread friendly result.
if (newLine) {
out.println();
out.println(sb.toString());
} else {
out.print(sb.toString());
}
out.flush();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册