problem in using the thread when adding object dynamically
Posted on 2004-04-08
i have a good question here.
I have a class 'Feeder'(1) which inplements 'Runnable'(2).
There are two methods in (1) they are add(), and other is run(); There is a vector named 'allBufers"
the add method adds an object(which contains another vector, in vector contains 1000 elements) into vector 'allBufers' .
the run method(which runs continuosly by taking 1st object, 2nd obect and ..till all the objects in vector and again starts from the first after completing all the objects.) takes each object from 'allBufers' and processes the vector present in object. The objects are added dynamically into vector 'allBufers'.
The problem is once i run the method 'run' and add an object to vector 'allBufers' it is not recognising that. I dont know if there is flaw in my understading or implementation.
here is the snipplet of code.
* Copyright: Copyright (c) 2004
* @version 1.0
public class Feeder implements Runnable
Vector allBufers=new Vector();
public void add(FeederComparable toFeed)
public void run()
System.out.println( (String)fc.vct.get(i) )
}//end of for
}//end of another for
}//end of while
}//end of run
}//end of class
this is the test which runs this.
public class TestFeeder
public static void main(String args)
FeederComparable fc1=new FeederComparable(b1,filename1,inputrate1);
FeederComparable fc2=new FeederComparable(b2,filename2,inputrate2);
FeederComparable fc3=new FeederComparable(b3,filename3,inputrate3);
FeederComparable fc4=new FeederComparable(b4,filename4,inputrate4);
Feeder f=new Feeder();
int the TestFeeder after adding the first object the run method displays all the content of vector in first object.
but i am not able to add anymore objects to the vector.
I think you got the question clear. If you have any problem in undertanding this question let me know.
vamshi krishna pajjuri