Reputation: 988
//News object
var newsItem = function(heading, type, time, details, ...)
{
this.heading = heading;
this.type = type;
this.time = time;
this.details = details;
....
};
// array of all newsItem objects
var newsItems = [news1, news2, news....];
I do two things with my above node.js server side code:
Question:
How do I make sure that when I am updating my newsItems object I dont use it to create html.
Since this is multi threaded, one thread serving a request and background thread updating the object from the news site. I need some kind of locking here in javascript. I am running into race condition here.
Thanks a lot.
Upvotes: 1
Views: 707
Reputation: 847
If you are running Node.js as your server, you don't need any lock. It's a single-thread environment.
Upvotes: 2