package com.bugsnag;

import java.util.Date;

class Session {

    private final String id;
    private final Date startedAt;

    private int handledCount;
    private int unhandledCount;

    Session(String id, Date startedAt) {
        this.id = id;
        this.startedAt = new Date(startedAt.getTime());
    }

    synchronized int getHandledCount() {
        return handledCount;
    }

    synchronized void incrementHandledCount() {
        this.handledCount++;
    }

    synchronized int getUnhandledCount() {
        return unhandledCount;
    }

    synchronized void incrementUnhandledCount() {
        this.unhandledCount++;
    }

    String getId() {
        return id;
    }

    Date getStartedAt() {
        return new Date(startedAt.getTime());
    }
}

package com.bugsnag;

import java.util.Date;
import java.util.concurrent.atomic.AtomicInteger;

class Session {

    private final String id;
    private final Date startedAt;
    private final AtomicInteger handledCount;
    private final AtomicInteger unhandledCount;

    Session(String id, Date startedAt) {
        this.id = id;
        this.startedAt = new Date(startedAt.getTime());
        this.handledCount = new AtomicInteger(0);
        this.unhandledCount = new AtomicInteger(0);
    }

    int getHandledCount() {
        return handledCount.get();
    }

    void incrementHandledCount() {
        this.handledCount.incrementAndGet();
    }

    int getUnhandledCount() {
        return unhandledCount.get();
    }

    void incrementUnhandledCount() {
        this.unhandledCount.incrementAndGet();
    }

    String getId() {
        return id;
    }

    Date getStartedAt() {
        return new Date(startedAt.getTime());
    }
}

use atomic integer to count session handled count