This language bar is your friend. Select your favorite languages!

Idiom #33 Atomically read and update variable

Assign variable x the new value f(x), making sure that no other thread may modify x between the read and the write.

#Edit dateEdit SummaryEditor
👁 Δ 22 2017-05-27, 12:03 [Go] It is more idiomatic to declare mutex as a value. +demoURL programming-idioms.org
👁 Δ 21 2016-03-29, 13:42 New PHP implementation by user [AgillaDev]
👁 Δ 20 2016-03-20, 23:33 [Pascal] dsgfdfg
👁 Δ 19 2016-03-20, 23:33 New Pascal implementation by user [JPSII]
👁 Δ 18 2016-02-18, 16:57 New Python implementation by user [TinyFawks]
👁 Δ 17 2016-02-16, 20:22 New Python implementation by user [TinyFawks]
👁 Δ 16 2016-01-01, 01:38 [Go] Comment emphasize
👁 Δ 15 2016-01-01, 00:45 New Go implementation by user [lck]
👁 Δ 14 2015-11-30, 12:37
👁 Δ 13 2015-10-29, 14:05
👁 Δ 12 2015-10-18, 13:19
👁 Δ 11 2015-09-06, 16:12
👁 Δ 10 2015-09-05, 16:33
👁 Δ 9 2015-09-05, 16:32
👁 Δ 8 2015-09-03, 17:05
👁 Δ 7 2015-09-03, 17:05
👁 Δ 6 2015-08-21, 23:14
👁 Δ 5 2015-08-20, 18:16
👁 Δ 4 2015-08-20, 12:00
👁 Δ 3 2015-08-20, 11:34
👁 Δ 2 2015-08-01, 01:54
1 2015-05-06, 21:04