更新时间:2021-12-21 23:14:28
看着您的代码,似乎线程选择了一个文件再次发布,而另一个线程选择了它进行发布.这就是为什么没人能删除它的原因. 它必须仅是并发问题.您应该根据以下准则重新设计代码:可以同时运行的步骤和不能同时运行的步骤. 因此,整个过程中的步骤如下:
Looking at your code it seems when one file is picked by thread for publishing again another thread is picking it up for publishing. That's why no one is able to delete it. It must be concurrency issue only. You should redesign code based up on criterion : steps which can be run concurrently and those which cannot be. So steps in the entire process are :
此外,选择文件后,您可以将其读入缓冲区,将其删除,然后继续进行发布.这样可以确保主线程不会将此文件分配给其他线程.
Also the moment a file is selected, you can read it into buffer , delete it and then continue with publish. This will make sure that main thread does not assign this file to some other thread.