zoukankan      html  css  js  c++  java
  • (六)java多线程之ReadWriteLock

    本人邮箱: kco1989@qq.com
    欢迎转载,转载请注明网址 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();
                    }
                }
            }
        }
    }
    

    这里需要注意以下几点

    1. 读文件操作比写文件操作频繁,这样才能看到边写边读的效果,这就需要在释放锁的时候,让写线程久一点,让读线程少一点
    2. 还有我这里采用判断标记位的方式,让读线程停止操作
    • 最后,我们需要写一个测试类 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"));
            List<Thread> readThreadList = new ArrayList<>();
            List<ReadRunnable> 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();
            }
        }
    }
    
    

    测试类,需要注意以下几点

    1. 创建了三个写操作,
    + 第一个依次写入26个大写字母
    + 第二个依次写入26个小写字母
    + 弟三个依次写入0-9十个数字
    
    1. 创建了五个读操作,让它们不断的读取文件
    2. 当全部写操作结束时,这停止这五个读操作

    运行程序,结果如下

    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: Aa0Bb1Cc2Dd3E
    Thread-1 write e
    Thread-2 write 4
    Thread-5 read: Aa0Bb1Cc2Dd3Ee4
    Thread-4 read: Aa0Bb1Cc2Dd3Ee4
    Thread-7 read: Aa0Bb1Cc2Dd3Ee4
    Thread-6 read: Aa0Bb1Cc2Dd3Ee4
    Thread-3 read: Aa0Bb1Cc2Dd3Ee4
    Thread-0 write F
    Thread-1 write f
    Thread-2 write 5
    Thread-5 read: Aa0Bb1Cc2Dd3Ee4Ff5
    Thread-4 read: Aa0Bb1Cc2Dd3Ee4Ff5
    Thread-7 read: Aa0Bb1Cc2Dd3Ee4Ff5
    Thread-3 read: Aa0Bb1Cc2Dd3Ee4Ff5
    Thread-6 read: Aa0Bb1Cc2Dd3Ee4Ff5
    Thread-7 read: Aa0Bb1Cc2Dd3Ee4Ff5
    Thread-4 read: Aa0Bb1Cc2Dd3Ee4Ff5
    Thread-5 read: Aa0Bb1Cc2Dd3Ee4Ff5
    Thread-6 read: Aa0Bb1Cc2Dd3Ee4Ff5
    Thread-3 read: Aa0Bb1Cc2Dd3Ee4Ff5
    Thread-0 write G
    Thread-1 write g
    Thread-4 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg
    Thread-3 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg
    Thread-7 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg
    Thread-5 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg
    Thread-6 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg
    Thread-2 write 6
    Thread-4 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6
    Thread-3 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6
    Thread-7 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6
    Thread-5 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6
    Thread-6 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6
    Thread-4 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6
    Thread-0 write H
    Thread-7 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6H
    Thread-5 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6H
    Thread-3 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6H
    Thread-6 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6H
    Thread-1 write h
    Thread-4 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh
    Thread-2 write 7
    Thread-5 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7
    Thread-3 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7
    Thread-7 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7
    Thread-6 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7
    Thread-4 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7
    Thread-0 write I
    Thread-4 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7I
    Thread-6 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7I
    Thread-5 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7I
    Thread-7 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7I
    Thread-3 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7I
    Thread-1 write i
    Thread-3 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7Ii
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j9KkLlMmOoOoPpQqRrSsTtUuVvWwXxYyZz
    Thread-3 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7Ii8Jj9KkLlMmOoOoPpQqRrSsTtUuVvWwXxYyZz
    Thread-3 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7Ii8Jj9KkLlMmOoOoPpQqRrSsTtUuVvWwXxYyZz
    Thread-7 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7Ii8Jj9KkLlMmOoOoPpQqRrSsTtUuVvWwXxYyZz
    Thread-5 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7Ii8Jj9KkLlMmOoOoPpQqRrSsTtUuVvWwXxYyZz
    Thread-4 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7Ii8Jj9KkLlMmOoOoPpQqRrSsTtUuVvWwXxYyZz
    Thread-6 read: Aa0Bb1Cc2Dd3Ee4Ff5Gg6Hh7Ii8Jj9KkLlMmOoOoPpQqRrSsTtUuVvWwXxYyZz
    

    通过运行结果,我们可以发现,读写操作是互不干扰的.每次写操作释放完锁,读操作都可以把之前写的数据全部读取出来.


    打赏

    如果觉得我的文章写的还过得去的话,有钱就捧个钱场,没钱给我捧个人场(帮我点赞或推荐一下)
    微信打赏
    支付宝打赏

  • 相关阅读:
    【BUUCTF】WEB SECRET FILE
    你是如何让函数返回IEnumerable<T>的
    对Closure的再思考
    旋转的女郎
    Tools in Visual Studio 2010
    解析命令行的正则表达式
    Closure中关于递归的一点补充
    对C++和C#中多态及类型转换的理解(二)
    对C#和C++0x中Lamda表达式的简略对比
    对C++和C#中多态及类型转换的理解(一)
  • 原文地址:https://www.cnblogs.com/kco1989/p/6760856.html
Copyright © 2011-2022 走看看