Hi all,
I know that Vector is synchronized,
when I run the following program
public class ClassA extends Thread{
static Vector<Integer > v=new Vector<Integer>();
public void run()
{
callMethod();
}
public void callMethod() {
System.out.println(v.size());
v.add(0);
System.out.println(v.size());
v.remove(0);
}
public static void main(String[] args) {
for(int i=0;i<1000;i++)
{
ClassA a=new ClassA();
a.start();
}
}
When I run the above program i am expecting result as 0 1..0 1... 0 1.. because vector internally sychronized ,
but when i give sychronize in externally its working fine
i.e when i change method as public static synchronized void callMethod() { then its working fine
So vector sychnronization where it works
could any one help me
thanks in advance