使用多线程进行文件读取写入 [英] file reading writing using multithreading

查看:242
本文介绍了使用多线程进行文件读取写入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用Java编写一个程序,其中一个线程正在读取文件,而另一个线程正在写入

I want to make a program in java in which one thread is reading a file and other is writing in

它.有人请提供任何参考链接给我,我可以在其中找到

it. Anybody please provide me any reference link where I can find the code snippets for the

一样吗?

推荐答案

您不应同时读写文件.最好的情况是,您最终会遇到数据损坏或IO错误的情况.

You shouldn't read and write to a file at the same time. In the best case, you'll end up with corrupted data, or an IO error.

如果用于进程间通信,则应改用套接字或JMS之类的更高级别的系统.

If it's for inter-process communication, you should instead use sockets or higher-level systems like JMS.

这篇关于使用多线程进行文件读取写入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆