File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
src/main/java/org/apache/ibatis/executor Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 2323 * 错误上下文
2424 */
2525public 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 );
You can’t perform that action at this time.
0 commit comments