相关疑难解决方法(0)

Fastest way to sum integers in text file

Question

Suppose you have a large ASCII text file, with a random non-negative integer on each line, each in the range from 0 to 1,000,000,000. There are 100,000,000 lines in the file. What's the fastest way to read through the file and calculate the sum of all the integers?

Constraint: we've got 10MB of RAM to work with. The file is 1GB in size, so we don't want to read the whole thing in and then process it.

Here are …

java performance file-io

48
推荐指数
3
解决办法
6703
查看次数

读取单个文件的Java多线程应用程序

我目前编写的程序使用32个线程并为每个线程读取1个文件(因此32个.txt文件).多线程与CPU速度无关,但是每秒对BING的api进行32次调用要快得多1.每个.txt文件都包含一个搜索查询列表.我创建一个线程,它从文件中一次读取一行.是否可以创建所有32个线程并将它们指向单个.txt文件?

java multithreading

2
推荐指数
1
解决办法
3594
查看次数

标签 统计

java ×2

file-io ×1

multithreading ×1

performance ×1