开发者

Race conditions with setTimeout in a Firefox extension?

What happens when I call setTimeout in a firefox extension? Is there ever a condition in which multiple callbacks can 开发者_如何学Crun simultaneously?

My firefox extension contains an array of URLs that I want to take screenshots of. My extension opens 5 tabs, and sets the URLs of these tabs to be the first 5 URLs in the array. Once a page finishes loading in tab N, I want to wait 30 seconds, take a screenshot, and then pop the next URL off the array and load it in tab N. The process repeats itself until the list of URLs is empty.

How can I be sure that each URL is processed exactly once? If I was writing this in java I would just synchronize all accesses to my URL list. How can I achieve this in a Firefox extension?


Javascript is completely single-threaded (except for the new Workers feature, which is separate).

No two callbacks can ever run simultaneously.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜