![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
多线程学习
熊小天
这个作者很懒,什么都没留下…
展开
-
java多线程学习(一)---线程互斥
1、同时启动2个线程public class TraditionalThreadSynchronized { public static void main(String[] args) { new TraditionalThreadSynchronized().init(); } private void init(){ Output outp原创 2017-11-29 22:19:36 · 196 阅读 · 0 评论 -
java多线程学习(二)---线程通信
子线程循环5次,接着主线程循环10次,接着又回到子线程循环5次,接着再回到主线程又循环10次,如此循环50次,请写出代码public class TraditionalThreadCommunication { public static void main(String[] args) { Business business = new Business();原创 2017-11-30 21:21:55 · 146 阅读 · 0 评论 -
java多线程学习(三)---线程范围内数据共享
初次尝试public class ThreadScopeShareData { private static int data = 0; public static void main(String[] args) { for (int i = 0; i <2 ; i++) { new Thread(new Runnable() {原创 2017-11-30 22:07:34 · 190 阅读 · 0 评论 -
java多线程学习(四)---ThreadLocal和单例实现线程内对象的共享
public class ThreadLocalTest { private static ThreadLocal<Integer> x = new ThreadLocal<Integer>(); private static ThreadLocal<MyThreadScopeData> myThreadScopeData = new ThreadLocal<MyThreadScop原创 2017-12-01 22:05:16 · 1049 阅读 · 0 评论