在前两篇博客的引导下可以很容易的理解这个内容:
synchronized代码块的简易使用说明: https://blog.csdn.net/whyfive4/article/details/91403040
文件的输入(或是键盘输入)追加至文件中 笔记: https://blog.csdn.net/whyfive4/article/details/91394829
因此,不需要什么引入了.
(注意:需要在 当前目录的RWtext.txt 中写入内容..不然显示空白)
代码:
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
public class Try_ThreadCreate {
private File file = null;
public static void main(String[] args) {
File file = new File(".//RWtext.txt");
Try_ThreadCreate test_Thread = new Try_ThreadCreate(file);
Readthread tReadthread = new Readthread(test_Thread);
Writethread writethread = new Writethread(test_Thread);
tRea
同一文件的互斥读写
最新推荐文章于 2021-05-07 00:37:08 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)