Skip to content

Instantly share code, notes, and snippets.

@koush
Created September 14, 2011 05:02

Revisions

  1. koush created this gist Sep 14, 2011.
    18 changes: 18 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    new Thread() {
    var entity = db.get('foo');
    // entity.siblings = [] due to race condition
    entity.siblings.push('boo');
    // entity.siblings = ['boo']
    db.put('foo', entity);
    // one of these puts overwrote the other...
    }.start();


    new Thread() {
    var entity = db.get('foo');
    // entity.siblings = [] due to race condition
    entity.siblings.push('bar');
    // entity.siblings = ['bar']
    db.put('foo', entity);
    // one of these puts overwrote the other...
    }.start();