Normally you wouldn't load the whole index into memory and then write the whole index back to disk later.
One option is to have the index primarily on disk, and just modify the file on the disk directly. To avoid race conditions, you use some form of a lock. You can globally lock the file for writing if updates are rare. If you want to have more fine grained locking then you need to make more decisions about the structure of the index on disk.
Another option is to have the index in memory, and just maintain a "copy" on disk for recovery purposes. In that case, everyone updating the index would manipulate eventually the same, shared in-memory index, and access to that would be protected by global or fine-grained operating system level locks.