Multiple threads accessing same file

  • Автор темы Автор темы Stereomike
  • Дата начала Дата начала

Stereomike

Client
Регистрация
29.03.2011
Сообщения
221
Реакции
30
Баллы
0
With a template that runs on e.g. 40 threads, but they use the same resource files (e.g. accounts.txt) what do I have to do, to make sure, these threads don't mess with the file?

I know if two threads try to write to the same file, there's a file block for the second (and following thread).
Is it the same for reading? get files blocked on reading?

And if a step encounters a file block, it will fail. So I have to loop it to try again, right?

Can I wait less than a second (pause -1-) before looping?
 
Same question here.
 
hmm I wonder why this hasnt been replied? May be ZP will mess up with the files.
 
Well firstly files are locked when they get a request on writing and threads stay in queue to work with the file
second with reading, it doesn't matter how many threads to read
file system solves this task
even if there is no access to the file, ZennoPoster waits about a second and try again. So 3 times, only after these attempts it will generate an error that the file is not readable
 
if u are reading lines from a file, using multithread, make sure u get the entire line and delete it in the same step. if u use count of strings and then pick a bit of the line here and another bit of the line there and more bits after :D , there will be enough time for another thread to pick the same line ( which will nmess up the all thing), if u only delete the line after getting the last bit u need. just take the all string delete imediatly and then that string stays in memory, use split the result of that to get the several bits, but the line was long way gone from the file on the first step...
 

Кто просматривает тему: (Всего: 0, Пользователи: 0, Гости: 0)