开发者

Behaviour in file writing by multiple threads

Many threads are writin开发者_如何学Gog StringBuffer to same file. StringBuffer contains around 100 lines. What is the output in file if multiple threads write to same file. Is each output from different threads mixup in file or they appear sequentially.


all of the above plus an exception could be thrown on one or more of the threads

Without some sort of synchronisation between the threads the result is non deterministic.


The data is likely to appear in the order it is written. However, unless you control this, that order is likely to be somewhat random.

Using multi-threads is also likely to be much slower, esp for such a small file. Its could be as many times slower as you have threads.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜