并发编程
文章平均质量分 70
个人知识管理布道师
这个作者很懒,什么都没留下…
展开
-
多线程编程入门(2):线程的通信(wait,notify)
package com.test.thread; /* * 线程的通信(交替打印number值,1,0,1,0,1,0.......) * wait,notify */ public class Simple { private int number; public synchronized void increase(){ if(0!=number){//1 try原创 2016-07-26 01:07:52 · 315 阅读 · 0 评论 -
多线程编程入门(17):线程同步工具之CountDownLatch
package cn.itcast.heima2; import java.util.concurrent.CountDownLatch; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class CountDownLatchTest { public原创 2016-08-06 23:00:33 · 302 阅读 · 0 评论 -
多线程编程入门(14):Condition实现线程通信
1 Condition的功能类似在传统线程技术中的Object.wait和Object.notify的功能. package cn.itcast.heima2; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.lock原创 2016-08-02 22:45:43 · 444 阅读 · 0 评论 -
多线程编程入门(13):读写锁的使用(ReentrantReadWriteLock)
package cn.itcast.heima2; import java.util.HashMap; import java.util.Map; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; /* * 利用Reentrant原创 2016-08-02 21:20:00 · 281 阅读 · 0 评论 -
多线程编程入门(12):锁(Lock)
package cn.itcast.heima2; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; public class LockTest { public static void main(String[] args) { final Out原创 2016-08-02 01:54:50 · 350 阅读 · 0 评论 -
多线程编程入门(11):Callable和Future
1 使用Demo package cn.itcast.heima2; import java.util.Random; import java.util.concurrent.Callable; import java.util.concurrent.CompletionService; import java.util.concurrent.ExecutorCompletion原创 2016-08-02 00:27:36 · 391 阅读 · 0 评论 -
多线程编程入门(10):线程池
package cn.itcast.heima2; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; public class ThreadPoolTest { public static原创 2016-08-01 23:29:55 · 330 阅读 · 0 评论 -
多线程编程入门(9):原子性操作类(java.util.concurrent.atomic)
1 java.util.concurrent.atomic.AtomicInteger An int value that may be updated atomically,用途举例,统计某个网页的访问次数,普通的整形变量自增统计有并发问题. 2 java.util.concurrent.atomic.AtomicIntegerArray An int array in w原创 2016-08-01 22:28:54 · 287 阅读 · 0 评论 -
多线程编程入门(16):线程同步工具之CyclicBarrier
package cn.itcast.heima2; import java.util.concurrent.CyclicBarrier; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class CyclicBarrierTest { public stat原创 2016-08-05 00:58:04 · 341 阅读 · 0 评论 -
多线程编程入门(15):线程同步工具之Semaphore(信号量)
package cn.itcast.heima2; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.Semaphore; public class SemaphoreTest { public static v原创 2016-08-04 01:25:10 · 553 阅读 · 0 评论 -
多线程编程入门(8):线程范围内的共享变量之ThreadLocal
package cn.itcast.heima2; import java.util.HashMap; import java.util.Map; import java.util.Random; //ThreadLocal方式实现线程范围内的共享变量 public class ThreadLocalTest { private static Map threadData = ne原创 2016-07-31 00:06:28 · 412 阅读 · 0 评论 -
多线程编程入门(7):线程范围内的共享变量
package cn.itcast.heima2; import java.util.HashMap; import java.util.Map; import java.util.Random; //线程范围内的共享变量 public class ThreadScopeShareData { private static Map threadData = new HashMap(原创 2016-07-30 17:15:02 · 395 阅读 · 0 评论 -
多线程编程入门(6):一道线程同步与通信面试题
package cn.itcast.heima2; /* * 子线程循环10次,接着主线程循环100次,接着又回到子线程循环10次,接着又回到主线程又循环100次, * 如此循环50次。请写出程序 * */ public class TraditionalThreadCommunication { public static void main(String[] args) {原创 2016-07-30 16:15:31 · 520 阅读 · 0 评论 -
多线程编程入门(5):传统定时器的使用
1 一个定时任务实现隔,2秒,4秒,2秒,4秒...定时执行 2 实现方案Apackage cn.itcast.heima2; import java.util.Date; import java.util.Timer; import java.util.TimerTask; public class TraditionalTimerTestA { static class MyT原创 2016-07-30 11:36:15 · 343 阅读 · 0 评论 -
多线程编程入门(4):wait,notify方法使用注意事项
1 问题 2 代码 public class WaitAndNotify1 { public static void main(String[] args) { Thread t1=new Thread(new Runnable(){ @Override public v原创 2016-07-27 17:46:32 · 969 阅读 · 0 评论 -
多线程编程入门(3):线程状态图
原创 2016-07-26 01:39:53 · 326 阅读 · 0 评论 -
多线程编程入门(1):线程的实现,停止,同步,通信
package com.test.thread; /* * 线程的实现1:继承Thread类,重写run */ public class ThreadTest { public static void main(String[] args) { Thread1 thread1 = new Thread1(); Thread1 thread2 = new Thread1();原创 2016-07-25 22:34:26 · 328 阅读 · 0 评论 -
多线程编程入门(18):线程同步工具之Exchanger
package cn.itcast.heima2; import java.util.concurrent.Exchanger; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class ExchangerTest { public static v原创 2016-08-06 23:25:45 · 364 阅读 · 0 评论