synchronized - How to synchronize access to private members of a javascript object -
i have javascript object created follows:
var ccstattracker = (function (){ ccmap:{ "1":["1","2","3","4"], "2":["4","5"]; } return { modifyccmap: function (){ // code takes following actions: // - adds/removes keys. // - modifies arrays stored values against keys in map. } } )();
i have dhtmlxgrid component displays grid in form of rows , columns. when edit cell in grid, "oneditcell" event called. now, want call ccstattracker.modifyccmap() event handler function attached "oneditcell" event. go on modifying cells, event called asynchronously in turn call function "modifyccmap" modify private member "ccmap" of javascript object. latest state of ccmap seen 2 calls might different right? best way handle this? there "synchronized" in javascript in java?
please me determine approach want take implementing this.
javascript single-threaded (web-workers aside moment), nothing happens asynchronously (or matter) - code: event handlers, timeouts, callbacks, etc. - run in same thread, 1 after another.
thus don't need synchronization in javascript. given piece of code in javascript guaranteed executed single thread. how cool that?
Comments
Post a Comment