package com.example.sync;

public class StaticSynchronizedExample {

	public static void main(String[] args) {

		// no need to create object of StaticSharedResource

		// create the static worker objects
		StaticWorker worker1 = new StaticWorker();
		StaticWorker worker2 = new StaticWorker();

		worker1.start();
		worker2.start();

		try {
			worker1.join();
			worker2.join();
		} catch (Exception e) {
			// TODO: handle exception
		}

		// call the static method to get counter value
		System.out.println("Final counter value: " + StaticSharedResource.getCounter());

		// use static when you create utility (shared) codes
		// System and Math class is an example of utility class
		System.out.println(Math.random());
	}

}
