Skip to content

Commit 4660290

Browse files
authored
Merge pull request tuguangquan#4 from 20100507/master
ErrorContext增加部分注释
2 parents 21dbf87 + 5b76c2f commit 4660290

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/main/java/org/apache/ibatis/executor/ErrorContext.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
* 错误上下文
2424
*/
2525
public class ErrorContext {
26-
26+
// 获得 \n 不同的操作系统不一样
2727
private static final String LINE_SEPARATOR = System.getProperty("line.separator","\n");
2828
//每个线程给开一个错误上下文,防止多线程问题
2929
private static final ThreadLocal<ErrorContext> LOCAL = new ThreadLocal<ErrorContext>();
@@ -35,14 +35,16 @@ public class ErrorContext {
3535
private String message;
3636
private String sql;
3737
private Throwable cause;
38-
38+
39+
//单例模式
3940
private ErrorContext() {
4041
}
4142

4243
//工厂方法,得到一个实例
4344
public static ErrorContext instance() {
44-
//因为是多线程,所以用了ThreadLocal
45+
//因为是多线程,所以用了ThreadLocal 线程安全
4546
ErrorContext context = LOCAL.get();
47+
//懒汉 单例模式
4648
if (context == null) {
4749
context = new ErrorContext();
4850
LOCAL.set(context);

0 commit comments

Comments
 (0)