我有以下算法来处理文件:
//open ifstram to read each line
//open ofstream to output each line
while (getline(ifstream, line1)){
getline(ifstream, line2) ;
getline(ifstream, line3) ;
getline(ifstream, line4) ;
//
getline(ifstream, line10) ;
for(int i = 1 ; i <= 10 ; i++)
// process line number i (some sort of character replacement, substring extraction)
output each line
}
现在,为了让我的代码更快,我想执行多线程。但是,我不明白,如何使用多线程运行上述算法,因此我将获得更快和正确的输出。任何建议都会有所帮助。