---
title: "Discussion on \"Why Your `counter++` Is Lying to You: A Practical Guide to Race Conditions in Java\" | Hashnode"
description: "Discussion on \"Why Your `counter++` Is Lying to You: A Practical Guide to Race Conditions in Java\". You wrote a counter. It increments. You ran it across a few threads, summed the results, and got a number that was almost right — off by a handful, in a way that changes every run and never reproduces"
url: "https://hashnode.com/posts/why-your-counter-is-lying-to-you-a-practical-guide-to-race-conditions-in-java/6a3bebcb9ae78bf5ae6b3e7d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Why Your \`counter++\` Is Lying to You: A Practical Guide to Race Conditions in Java](https://harrishdhaithya.hashnode.dev/why-your-counter-is-lying-to-you-a-practical-guide-to-race-conditions-in-java?utm_source=hashnode&utm_medium=feed)

You wrote a counter. It increments. You ran it across a few threads, summed the results, and got a number that was almost right — off by a handful, in a way that changes every run and never reproduces

Jun 24 · 16 min read · harrishdhaithya.hashnode.dev  
Read the article

## Written by

[HARRISH DHAITHYA K A](https://hashnode.com/@harrishdhaithya)

@harrishdhaithya

  
[View profile](https://hashnode.com/@harrishdhaithya)

## Responses 1

Markdown supported · ⌘↵ to post

[Mohankumar Muthusamy](https://hashnode.com/@akpmohan)

[Jun 26](https://hashnode.com/posts/why-your-counter-is-lying-to-you-a-practical-guide-to-race-conditions-in-java/6a3bebcb9ae78bf5ae6b3e7d/comment/6a3e86be5c71d50f7be622cc)

Insightful!
