试题详情
- 单项选择题 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
- A
关注下方微信公众号,在线模考后查看
热门试题
- int i= 1,
- 下面有关maven和ant的描述,描述错
- Click the
- 有一堆桃子(个数不超过1000),如果分
- 求s=a+aa+aaa+aaaa+aa.
- 在输入流的read方法返回哪个值的时候表
- 在一个函数中,允许几return语句?(
- 对于下面这段代码,以下说法正确的是:()
- What is th
- Click the
- TCP链接中主动断开链接netstat观
- package foo;&e
- 举例说明getter和setter方法的
- What is th
- 猴子吃桃问题:猴子第一天摘下若干个桃子,
- 下面有关java 抽象类和接口的区别,说
- In which
- class WhileTes
- 1. public&ensp
- A developer&en