A Filedoes allow writing to it from multiple threads at the same time, but be careful, unless the things you write are very short, you will get your writes interleaved. To prevent this, I recommend putting a lock around it anyway.
Lock is bad, if you don't mind the order of writes, you could use a MPSC channel to send them to another thread or task which consume them and writes to file.
If your writes are append-only, remember set the append flag when opening the file. Which prevents unnecessary reads from disk.
In this case, use lock means threads must do the writes by themselves. Disk I/O is slow, and there's only one thread can do the write at the same time, others must block. So the writes would be doing sequecially and there's lock/unlock overhead.
Use a separate thread to do the writes means there's no need to block the thread and waiting for write completion. And a lot of channel implementations are lock-free, which is usually faster than lock-based implementation.
The lock might require one of your writing threads to wait without doing anything useful while another is using the file. If you use a channel that feeds a dedicated writing thread, the messages get queued immediately and written as soon as the writer deals with everything in front of it in line.
It’s more performant, but might be undesirable in some circumstances: if you’re producing data faster than the disk can write, you’ll have an ever-growing in-memory buffer. Also, if you’re writing some kind of guaranteed-persistence software (like a database), the original thread may need to wait for its write to finish anyway.
I have written a simulator of a distributed system that runs a gazillion threads. Each thread produces trace records that are written to a single file. It is not uncommon for those records to appear out of order, e.g., the trace reports a message being received before it was sent. On rare occasions a record is incomplete, which I assume is caused by simultaneous writes.
These anomalies aren't a problem for me, since the trace is used only for debugging and analysis. You will have to be more careful than I have been if they are important to you.