If you just used an int or long variable then you would need synchronization – incrementing involves read / increment-locally / write, which is far from an atomic operation. (Even if the variable is volatile to avoid memory model concerns of staleness, you’d still have three distinct operations, with the possibility of being pre-empted between any pair of them.)
Fortunately Java provides AtomicInteger and AtomicLong which can be used without any synchronization:
private final AtomicLong counter = new AtomicLong();
...
counter.incrementAndGet(); // No need for synchronization