Skip to content

Instantly share code, notes, and snippets.

@koush
Created September 14, 2011 05:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koush/1215889 to your computer and use it in GitHub Desktop.
Save koush/1215889 to your computer and use it in GitHub Desktop.
fuuuuck.java
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();
@optedoblivion
Copy link

not synchronized ?

@koush
Copy link
Author

koush commented Sep 15, 2011

nah, i was just gisting something for a friend about atomicity of writes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment