Why the following code of multithreading is not working? The answer should be 20000 I believe
<p>Why am I not getting 20000 when the increment method is synchronized. I did the same thing with runnable and it worked.</p>

<pre><code>   public class ThreadClass extends Thread
    {
            static int count=0;
            public synchronized void increment()
            {
                count++;
            }

    public void run()
    {
        for(int i=0;i&lt;10000;i++)
        {
            increment();
        }
    }; 

}

public class Main {

    public static void main(String[] args) {

        ThreadClass t1=new ThreadClass();
        ThreadClass t2= new ThreadClass();

        t1.start();
        t2.start();

        try {
            t2.join();
            t1.join();
            } 
        catch (Exception e) 
            {
            e.printStackTrace();
            }
        System.out.println(ThreadClass.count);
    }

}
</code></pre>