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