摘要:本人邮箱欢迎转载转载请注明网址代码已经全部托管有需要的同学自行下载引言上一篇讲到了在同一个时间点只能用一个线程能够访问共享资源今天我们来讲一下读写锁读写锁提供了在同一个时间点可以有多个线程共享去读取共享资源当只有有一个线程去写共享资源主要是
引言本人邮箱:
欢迎转载,转载请注明网址 http://blog.csdn.net/tianshi_kco
github: https://github.com/kco1989/kco
代码已经全部托管github有需要的同学自行下载
上一篇讲到了ReentrantLock,在同一个时间点,只能用一个线程能够访问共享资源.今天我们来讲一下读写锁ReadWriteLock,读写锁提供了在同一个时间点,可以有多个线程共享去读取共享资源,当只有有一个线程去写共享资源.
ReadWriteLock主要是Lock锁使用的,提供一个读和一个写的操作.readLock可以在有多个线程同时操作直到没有写的操作.writeLock却在同一个时间点只能有一个线程在操作.
所有ReadWriteLock的实现类必须在writeLock写操作时,保证内存同步,同时还必须和readLock相关联,比如当一个线程获取到读锁时,这必须保证当前线程能在写锁释放后看到所有的更新操作.
首先定一个模拟读写文件的类MockFIle
public class MockFile { // 使用StringBuilder而不是使用StringBuffer // 是因为StringBuilder是线程不安全的,而StringBuffer是线程安全的 StringBuilder fileContent; public MockFile() { this.fileContent = new StringBuilder(); } public String readFile(){ try { Thread.sleep(10); String content = fileContent.toString(); Thread.sleep(10); return content; } catch (InterruptedException e) { return null; } } public void writeFile(char content){ try { Thread.sleep(10); fileContent.append(content); Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); } } }
注意在该类使用StringBuilder是因为这个类是线程不安全的
StringBuffer是线程安全的
之后编写读文件操作 ReadRunnable
public class ReadRunnable implements Runnable { ReadWriteLock lock; MockFile file; boolean isStop; public ReadRunnable(ReadWriteLock lock, MockFile file) { this.lock = lock; this.file = file; isStop = false; } @Override public void run() { Thread self = Thread.currentThread(); while(!isStop){ Lock lock = this.lock.readLock(); try { lock.lock(); String content = file.readFile(); System.out.println(self.getName() + " read: " + content); Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace(); }finally { lock.unlock(); try { Thread.sleep(50); } catch (InterruptedException e) { e.printStackTrace(); } } } } public void setStop() { isStop = true; } }
然后再编写 写文件操作 WriteRunnable
public class WriteRunnable implements Runnable { ReadWriteLock lock; MockFile file; String content; public WriteRunnable(ReadWriteLock lock, MockFile file, String content) { this.lock = lock; this.file = file; this.content = content; } @Override public void run() { Thread self = Thread.currentThread(); for (char ch : content.toCharArray()){ Lock lock = this.lock.writeLock(); try { lock.lock(); System.out.println(self.getName() + " write " + ch); file.writeFile(ch); Thread.sleep(20); } catch (InterruptedException e) { e.printStackTrace(); } finally { lock.unlock(); try { Thread.sleep(200); } catch (InterruptedException e) { e.printStackTrace(); } } } } }
这里需要注意以下几点
读文件操作比写文件操作频繁,这样才能看到边写边读的效果,这就需要在释放锁的时候,让写线程睡久一点,让读线程睡少一点
还有我这里采用判断标记位的方式,让读线程停止操作
最后,我们需要写一个测试类 TestMain
public class TestMain { public static void main(String[] args) { MockFile mockFile = new MockFile(); ReentrantReadWriteLock lock = new ReentrantReadWriteLock(); Thread thread1 = new Thread(new WriteRunnable(lock, mockFile, "ABCDEFGHIJKLMOOPQRSTUVWXYZ")); Thread thread2 = new Thread(new WriteRunnable(lock, mockFile, "abcdefghijklmoopqrstuvwxyz")); Thread thread3 = new Thread(new WriteRunnable(lock, mockFile, "0123456789")); ListreadThreadList = new ArrayList<>(); List readRunnables = new ArrayList<>(); for (int i = 0; i < 5; i ++){ ReadRunnable readRunnable = new ReadRunnable(lock, mockFile); readThreadList.add(new Thread(readRunnable)); readRunnables.add(readRunnable); } thread1.start(); thread2.start(); thread3.start(); for (Thread readThread : readThreadList){ readThread.start(); } while (thread1.isAlive() || thread2.isAlive() || thread3.isAlive()); for (ReadRunnable readRunnable : readRunnables){ readRunnable.setStop(); } } }
测试类,需要注意以下几点
创建了三个写操作,
+ 第一个依次写入26个大写字母 + 第二个依次写入26个小写字母 + 弟三个依次写入0-9十个数字创建了五个读操作,让它们不断的读取文件
当全部写操作结束时,这停止这五个读操作
运行程序,结果如下
Thread-0 write A Thread-1 write a Thread-2 write 0 Thread-4 read: Aa0 Thread-5 read: Aa0 Thread-7 read: Aa0 Thread-3 read: Aa0 Thread-6 read: Aa0 Thread-6 read: Aa0 Thread-3 read: Aa0 Thread-4 read: Aa0 Thread-7 read: Aa0 Thread-5 read: Aa0 Thread-0 write B Thread-6 read: Aa0B Thread-1 write b Thread-5 read: Aa0Bb Thread-3 read: Aa0Bb Thread-4 read: Aa0Bb Thread-7 read: Aa0Bb Thread-2 write 1 Thread-6 read: Aa0Bb1 Thread-5 read: Aa0Bb1 Thread-3 read: Aa0Bb1 Thread-4 read: Aa0Bb1 Thread-7 read: Aa0Bb1 Thread-0 write C Thread-7 read: Aa0Bb1C Thread-4 read: Aa0Bb1C Thread-5 read: Aa0Bb1C Thread-6 read: Aa0Bb1C Thread-3 read: Aa0Bb1C Thread-1 write c Thread-3 read: Aa0Bb1Cc Thread-4 read: Aa0Bb1Cc Thread-7 read: Aa0Bb1Cc Thread-5 read: Aa0Bb1Cc Thread-6 read: Aa0Bb1Cc Thread-2 write 2 Thread-3 read: Aa0Bb1Cc2 Thread-4 read: Aa0Bb1Cc2 Thread-5 read: Aa0Bb1Cc2 Thread-7 read: Aa0Bb1Cc2 Thread-6 read: Aa0Bb1Cc2 Thread-0 write D Thread-7 read: Aa0Bb1Cc2D Thread-6 read: Aa0Bb1Cc2D Thread-3 read: Aa0Bb1Cc2D Thread-4 read: Aa0Bb1Cc2D Thread-5 read: Aa0Bb1Cc2D Thread-1 write d Thread-2 write 3 Thread-7 read: Aa0Bb1Cc2Dd3 Thread-6 read: Aa0Bb1Cc2Dd3 Thread-3 read: Aa0Bb1Cc2Dd3 Thread-4 read: Aa0Bb1Cc2Dd3 Thread-5 read: Aa0Bb1Cc2Dd3 Thread-0 write E Thread-3 read: Aa0Bb1Cc2Dd3E Thread-6 read: Aa0Bb1Cc2Dd3E Thread-7 read: Aa0Bb1Cc2Dd3E Thread-4 read: Aa0Bb1Cc2Dd3E Thread-5 read: Aa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cc2Dd3Ee4Ff5Gg6Hh7Ii8Jj9KkLlMmOoOoPpQqRrSsTtUuVvWwXxYyZz Thread-3 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7Ii8Jj9KkLlMmOoOoPpQqRrSsTtUuVvWwXxYyZz Thread-3 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7Ii8Jj9KkLlMmOoOoPpQqRrSsTtUuVvWwXxYyZz Thread-7 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7Ii8Jj9KkLlMmOoOoPpQqRrSsTtUuVvWwXxYyZz Thread-5 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7Ii8Jj9KkLlMmOoOoPpQqRrSsTtUuVvWwXxYyZz Thread-4 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7Ii8Jj9KkLlMmOoOoPpQqRrSsTtUuVvWwXxYyZz Thread-6 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7Ii8Jj9KkLlMmOoOoPpQqRrSsTtUuVvWwXxYyZz
通过运行结果,我们可以发现,读写操作是互不干扰的.每次写操作释放完锁,读操作都可以把之前写的数据全部读取出来.
打赏如果觉得我的文章写的还过得去的话,有钱就捧个钱场,没钱给我捧个人场(帮我点赞或推荐一下)
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/67073.html
摘要:二接口简介可以看做是类的方法的替代品,与配合使用。当线程执行对象的方法时,当前线程会立即释放锁,并进入对象的等待区,等待其它线程唤醒或中断。 showImg(https://segmentfault.com/img/remote/1460000016012601); 本文首发于一世流云的专栏:https://segmentfault.com/blog... 本系列文章中所说的juc-...
摘要:返回与此锁相关联的给定条件等待的线程数的估计。查询是否有线程正在等待获取此锁。为公平锁,为非公平锁线程运行了获得锁定运行结果公平锁的运行结果是有序的。 系列文章传送门: Java多线程学习(一)Java多线程入门 Java多线程学习(二)synchronized关键字(1) java多线程学习(二)synchronized关键字(2) Java多线程学习(三)volatile关键字 ...
摘要:我们知道,的作用其实是对类的和的增强,是为了让线程在指定对象上等待,是一种线程之间进行协调的工具。当线程调用对象的方法时,必须拿到和这个对象关联的锁。 showImg(https://segmentfault.com/img/remote/1460000016012566); 本文首发于一世流云的专栏:https://segmentfault.com/blog... 一、Reentr...
摘要:此时线程和会再有一个线程能够获取写锁,假设是,如果不采用再次验证的方式,此时会再次查询数据库。而实际上线程已经把缓存的值设置好了,完全没有必要再次查询数据库。 大家知道了Java中使用管程同步原语,理论上可以解决所有的并发问题。那 Java SDK 并发包里为什么还有很多其他的工具类呢?原因很简单:分场景优化性能,提升易用性 今天我们就介绍一种非常普遍的并发场景:读多写少场景。实际工作...
摘要:线程安全的实现前面章节介绍了在现代环境下的实现观察者模式,虽然简单但很完整,但这一实现忽略了一个关键性问题线程安全。截止目前实现了线程安全,在接下来的章节中将介绍提取主题的逻辑并将其类封装为可重复代码单元的方式优缺点。 【编者按】本文作者是 BAE 系统公司的软件工程师 Justin Albano。在本篇文章中,作者通过在 Java8 环境下实现观察者模式的实例,进一步介绍了什么是观察...
摘要:二模式案例类数据类可以被多个线程同时访问。共享资源参与者代表和所共享的资源对象,提供不改变内部状态的操作,以及会改变内部状态的操作。读写锁参与者提供了对参与者进行操作和操作时需要的锁定。 一、定义 Read-Write Lock Pattern将读取与写入分开处理,在读取数据之前必须获取用来读取的锁定,而写入的时候必须获取用来写入的锁定。因为读取时实例的状态不会改变,所以多个线程可...
阅读 2511·2021-07-26 23:38
阅读 3415·2019-08-30 13:10
阅读 2291·2019-08-29 18:33
阅读 2293·2019-08-29 16:12
阅读 962·2019-08-29 10:59
阅读 1784·2019-08-26 17:40
阅读 746·2019-08-26 11:59
阅读 794·2019-08-26 11:41