multithreaded tablemodel - mutexes?
Hi
Ok I have a JTable with a TableModel extending DefaultTableModel.
All my calls goes through JTable to TableModel.
for example:
first invoked:
//In JTable
publicvoidsynchronized doSomethingWithRows()
{
int rows = tableModelName.getAllRows();
for(k=0; k<rows; k++)
{
System.out.println("TESTING!");
}
}
PROBLEM: In the above method doSomethingWithRows an OutOfBoundsException can occur ! because apparently the TableModel can change meanwhile(even though I have synchronized the entire method) from another thread.
Andthis is the method its calling...
//In TableModel
publicsynchronizedint getAllRows()
{
int rows= getRowCount();
return rows;
}
I apparently need to lock the tablemodel and would need some kind of mutexes. How do I lock an object in Java?
thx!>

