0

I have a global variable in jquery. Two diffirent functions reading and modifying this variable in runtime.

One jquery function is reading value from this variable on every 2000 seconds and resettng it. And, a SignalR method updating this variable whenever it gets any update from server.

Is there any way to lock that variable to others while reading or writing to it?

s.k.paul
  • 7,099
  • 28
  • 93
  • 168

1 Answers1

2

Javascript follows a single threaded execution pattern(except web workers) so there is no way for simultaneous modification/read of a variable.

Also read this

Community
  • 1
  • 1
Arun P Johny
  • 384,651
  • 66
  • 527
  • 531