On Thu, 25 Jan 2024 09:56:08 GMT, Alexey Ivanov <aiva...@openjdk.org> wrote:

> > > …I'm for replacing `Vector` with `ArrayList` for the `newFileCache` and 
> > > `newFiles` variables. These are local variables, they're not accessed 
> > > concurrently. Yet they're accessed from two threads: the current one and 
> > > the one where `ShellFolder.invoke` runs, so there could be a need to use 
> > > another synchronisation technique to ensure thread-safety between these 
> > > two threads.
> > 
> > 
> > Another Synchronization technique even after `synchronized (fileCache)`?
> 
> Yes, even after.

No, it's not needed, actually. `ShellFolder.invoke` executes the code directly 
on the same thread or passes it to COM thread on Windows. When it's passed to 
the COM thread, a `Future` object is used, which ensures synchronisation.

I submitted [JDK-8324973](https://bugs.openjdk.org/browse/JDK-8324973): 
_Replace Vector with ArrayList in BasicDirectoryModel.FilesLoader_.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/17462#discussion_r1471379466

Reply via email to