Understanding BufferedWriter in Java with Examples

When you use BufferedWriter to write, the data gets written to an internal buffer.
Only once the internal buffer is full OR if there is a need to flush, this data gets written to the target character stream/writer.
This buffering approach reduces the (costly) interactions with writing to the network or the disk thereby improving the performance compared to using non buffered writers.

3 ways to achieve thread safety in Java

Why is thread safety important in Java and three options with examples to implement thread safety in Java. Implement thread safety using Locks, proxies.