Making a Java class Thread safe : I am trying to understand as to how to make the Java class thread-safe.

    package com.test;
    public class ThreadBean {
    	private int x;
        public int getX() {
            return x;
        }
        public void setX(int x) {
            this.x = x;
        }
    }

Inorder to do this,I need to create another program that spawns the threads(lets say 2 threads) and then each of the two threads sets values using the setX().When the values are being read using getX() I should be able to see inconsistencies thanks to the above ThreadBean class not being threadsafe.This maybe a simplistic case but this is just for my understanding.Please advise.Thanks