Take the 2-minute tour ×

Many threads are writing 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.

share|improve this question

2 Answers 2

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.

share|improve this answer

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.

share|improve this answer

Your Answer


