**The idea:** I have a JAX-RS webservice servlet (Object called `webServlet`) which instantiates a data collecting Object `dataCollector` and passes this object on to multiple threads in their constructor. These threads query websites for results and then call the `dataCollector.add(result)` method to add the results to a Queue within the shared `dataCollector`.
**I have two questions regarding this idea:**
1) Can multiple threads call methods of a single shared object at the same time?
2) How does my `webServlet` object check when all threads are terminated to render a result page? Do I have to let my `webServlet` wait while all threads are running so I have a complete result list and how would I do that?
以上就是Java Threads calling methods on common Data Collector Object possible?的详细内容，更多请关注web前端其它相关文章！