- Never create a resource with open() or with open() inside run method of a worker thread. Create a resource in the main thread and pass the reference to the resource to the worker instead.
- with open() is better than open() for writers because it closes the writer automatically when the control exits its scope. This flushes all write buffer to the disk.
- If open() is used for write(), explicitly call f.close() or f.flush() as you would normally do in Java.
No comments:
Post a Comment