Cái này thì đọc từng file thôi, nhưng làm sao để tối ưu ->concurrency
Khi đọc file thì program cần phải đơi file được đọc lên thì mới xử lý tiếp được.
nếu chỉ có 1 thread thì nó như sau:
5 seconds reading file A (ví dụ 1 file đọc 5s)
2 seconds processing file A ( tìm kiếm chuỗi mất 2s)
5 seconds reading file B
2 seconds processing file B
-----------------------
14 seconds total
nếu có 2 thread
5 seconds reading file A
5 seconds reading file B + 2 seconds processing file A
2 seconds processing file B
-----------------------
12 seconds total
Như vậy sẽ ok hơn,
Nhưng bao nhiêu thread thì tối ưu?, đọc định luật Amdahl nhé
http://ktmt.github.io/blog/2014/05/19/dinh-luat-amdahl/