Java:如何存储处理不同文件的多个线程
我有一个服务器,它根据请求发送不同的文件(每个文件打开一个线程)。 每个线程都不知道他在创建时处理哪个文件,但只有在收到带有其名称的消息后,所以当时我需要以某种方式将其与文件关联起来。
我需要等待某个文件的所有线程结束的选项,当然 服务器中的所有线程。
整个线程的事情是通过线程组完成的, 至于文件,我想向每个文件添加一个线程列表(我已经有一个包装类),并添加等待某个文件的选项。 但我认为这不是一个好的解决方案,而且我需要使用一些并发集合,而且我找不到任何只是并发链表的东西。
有什么建议如何实施吗?
I have a server, that sends different files (each opening a thread) on request.
each thread doesn't know which file hes handling on creation but only once a message with its name is received, so at that time I need to associate it with the file somehow.
I need the option to wait for all the threads of a certain file to end, and of course
all the threads in the server.
The whole threads thing is done with a thread group,
as for the files, I wanted to add a list of threads to each file (I have a wrapper class for it already), and add the option to wait for a certain file.
but I don't think this is a good solution, plus I need to use some concurrent collection, and I cant find anything that is just a concurrent linked list.
Any suggestion how to implement this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我没有清楚地理解你的要求,但我认为这样的东西适合你:
I did not understand your requirement clearly, but I think something like this will work for you: