第十一章 Thread-Specific Storage
来源:互联网 发布:win8系统网络连接受限 编辑:程序博客网 时间:2024/06/05 05:06
背景介绍:类似与ThreadLocal,保存每个线程的内容、独有的数据、独有的字段、内存空间
public class Log { private static final ThreadLocal tsLogCollection = new ThreadLocal(); // 加入一个log public static void println(String s) { getTSLog().println(s); } // 关闭log public static void close() { getTSLog().close(); } // 取得线程特有的log private static TSLog getTSLog() { TSLog tsLog = (TSLog)tsLogCollection.get(); //如果线程是第一次呼叫,就建立新挡案并登陆log if (tsLog == null) { tsLog = new TSLog(Thread.currentThread().getName() + "-log.txt"); tsLogCollection.set(tsLog); } return tsLog; } /*private static PrintWriter writer = null; static { try { writer = new PrintWriter(new FileWriter("log.txt")); } catch (IOException e) { e.printStackTrace(); } } public static void println(String s) { writer.println(s); } public static void close() { writer.println("==== End of log ===="); writer.close(); }*/}
0 0
- 第十一章 Thread-Specific Storage
- Thread-Specific Storage
- Thread-Specific Storage
- Thread-Specific Storage 模式
- Thread Specific Storage
- Thread-Specific Storage Pattern
- 利用Thread-Specific Storage撰寫一個HibernateUtil
- 利用Thread-Specific Storage撰寫一個HibernateUtil
- 线程特有存储模式(Thread Specific Storage)
- 线程局部存储 Thread Local Storage 线程特定数据 Thread-Specific Data
- 多线程设计模式——Thread Specific Storage(线程特有存储)模式
- Thread-specific data
- Thread-specific data
- 线程私有数据thread-specific
- python thread wait until specific thread complete
- Thread-Local Storage
- TLS (Thread local storage)
- Thread-Local Storage(TLS)
- hadoop中job提交在yarn中的运行过程
- mybatis传递多个同类型参数
- leetcode-350-Intersection of Two Arrays II
- wxPython 把窗口部件放入框架中
- 《java web 学习笔记二》:html
- 第十一章 Thread-Specific Storage
- 大神教你如何在 Linux 中启用 Shell 脚本的调试模式
- line-height 百分比和数值设置行高
- PCC-F-NOERRFILE, unable to open error message file, facility PR2
- JSON 与JSONP的温习
- 剑指offer笔记
- 聊聊Twemproxy是什么
- javascript字典类
- ctivity的切换问题(activity与栈)