当前位置:SCJP程序员认证考试题库

问题:

[单选]

public class MyLogger { 
private StringBuilder logger = new StringBuuilder(); 
public void log(String message, String user) { 
logger.append(message); 
logger.append(user); 
} 
} 
The programmer must guarantee that a single MyLogger object works properly for a multi-threaded system. How must this code be changed to be thread-safe?() 

A .  synchronize the log method
B .  replace StringBuilder with StringBuffer
C .  No change is necessary, the current MyLogger code is already thread-safe.
D .  replace StringBuilder with just a String object and use the string concatenation (+=) within the log method

法兰的公称通径用DN表示,公称压力用字母()表示。 PA。 PN。 PY。 PZ。 “水族馆”的音乐再现内容是什么? 垂直的需求曲线的价格弹性一定等于无穷大。 简述气-水联合反冲洗工艺原理 学前儿童音乐课程内容的形式要素是什么?

public class MyLogger { 
private StringBuilder logger = new StringBuuilder(); 
public void log(String message, String user) { 
logger.append(message); 
logger.append(user); 
} 
} 
The programmer must guarantee that a single MyLogger object works properly for a multi-threaded system. How must this code be changed to be thread-safe?() 

参考答案:

  参考解析

本题暂无解析

在线 客服