uot;: op() {
            lock.lock();
            result = counter;
            lock.unlock();
            result;
        }
    };
};

/* Use the thread-safe counter */
counter = thread_safe_counter();
threads = [];

/* Create multiple threads that increment the counter */
i = 0;
while (i &lt; 10) {
    thread = $thread();
    thread.run(op() {
        j = 0;
        while (j &lt; 100) {
            counter.increment();
            j += 1;
        };
    });
    threads += thread;
    i += 1;
};

/* Wait f