0

I think each task will contain an instance of spout or bolt, and a while or for block calls them, is it right?

If so, since every task coordinates to one of some threads running in a worker process, and there is probability that two or more tasks of the same spout or bolt are assigned to the same worker, in this case, do we need to sync (especially if the spout or bolt contains critical resources such as static members)? Why?

4

1 回答 1

0

是的,同一个 spout/bolt 的多个任务可以分配给同一个 worker 并在同一个 JVM 中运行。我建议不要使用非线程安全的静态成员——在这种情况下,你不需要关心同步。

于 2013-04-24T21:18:21.947 回答