将多个线程与 RandomAccessFile 一起使用是否有助于提高性能? [英] Will using multiple threads with a RandomAccessFile help performance?
问题描述
我正在处理一个(数据库类)项目,其中数据存储在一个平面文件中.对于读/写,我使用 RandomAccessFile
类.我会从多线程中获得什么,并为每个线程提供一个 RandomAccessFile
的实例,还是一个线程/实例的速度也一样快?读/写有什么区别,因为你可以制作只能读而不能写的实例?
I am working on a (database-ish) project, where data is stored in a flat file. For reading/writing I'm using the RandomAccessFile
class. Will I gain anything from multithreading, and giving each thread an instance each of RandomAccessFile
, or will one thread/instance be just as fast? Is there any difference in reading/writing, as you can make instances that only do the reading, and can't write?
推荐答案
一个相当常见的问题.基本上使用多线程不会使您的硬盘驱动器运行得更快.相反,执行并发请求可能会使其变慢.
A fairly common question. Basically using multiple threads will not make your hard drive go any faster. Instead performing concurrent request can make it slower.
磁盘子系统,尤其是 IDE、EIDE、SATA,旨在实现最快的顺序读/写.
Disk subsystems, esp IDE, EIDE, SATA, are designed to read/write sequentially fastest.
这篇关于将多个线程与 RandomAccessFile 一起使用是否有助于提高性能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!