安全推送阵列,如何?担心与否? [英] push to array safely, how to? worry or not?

查看:71
本文介绍了安全推送阵列,如何?担心与否?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这可能是一个天真的问题。我经常发现我有多个等待返回的xhr请求。我跟踪我在javascript数组中发出的请求。也就是说,当发出新请求时,我将它添加到数组中,然后当线程完成时,我将其从数组中删除。

I think this may be a naive question. I often find that I've got multiple xhr requests waiting on returns. I keep track of the requests I've issued in a javascript array. that is, when a new request is made, I add it to the array, then when the thread completes I remove it from the array.

在多线程操作系统中,我会担心线程交叉,但我知道javascript是单线程的。我应该担心阵列是否一致?

In a multi-threaded OS, I'd be worried about threads crossing but I know javascript is single threaded. Should I worry about the array being consistent?

如果已经询问并回答了这个问题,很抱歉。我看了,没有找到数组安全推送的链接。

Sorry if this has been asked and and answered. I looked and did not find a link around array safe push.

推荐答案

不,你不应该担心。 JavaScript是单线程的,就像你说的那样。

No, you should not worry about it. JavaScript is single-threaded, like you said.

这篇关于安全推送阵列,如何?担心与否?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆