Java: Synchronizing ints

private static int increment() {
return ++i;
}
private static synchronized int increment() {
return ++i;
}

--

--

--

On a continuing learning journey..

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Consider the Value of #NoEstimates in Your Org anization

N-ary Tree Level Order Traversal — Medium

X431 Idiag Serial Number

Arrays in Python

Copy or move rows between sheets automatically

How to install Ubuntu on macOS Big Sur with VirtualBox

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Learn

Learn

On a continuing learning journey..

More from Medium

Java — Rewriting Traditional Codes With Streams #3 (collect)

Functional Programming In Java

Why Java is still a great programming language

Duke Cheers

Debugging RAM: Detect/Fix Memory Leaks in Managed Languages — Heap Deep Dive, Part 2