Multiple threads accessing same file

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?
 

Hoki

Client
Регистрация
24.04.2011
Сообщения
18
Благодарностей
2
Баллы
0
Same question here.
 

gcomm

Client
Регистрация
01.03.2011
Сообщения
332
Благодарностей
93
Баллы
28

helpot80

Client
Регистрация
28.05.2011
Сообщения
48
Благодарностей
0
Баллы
6
hmm I wonder why this hasnt been replied? May be ZP will mess up with the files.
 

Hungry Bulldozer

Moderator
Регистрация
12.01.2011
Сообщения
3 441
Благодарностей
831
Баллы
113
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
 

joma

Client
Регистрация
06.03.2011
Сообщения
107
Благодарностей
13
Баллы
0
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...
 

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