EOFException error in I/O. Are threads the problem?
Hi,
I have been using the following code for years now with now problem. Suddenly now that I am trying
to use it with 2 threads I get an EOFException. I thought that threads were supposed to be mutually
exclusive (in other words one cannot run until another one has finished). Both of my threads use
this code. Can anyone suggest a way that I could make sure only one thread at a time is trying
to I/O? I am new to threads.
Code:
public static void writeObj(Vector v, String s){
String dataloc2 = s;
Vector ObjectVector2 = new Vector();
ObjectVector2 = v;
try
{
FileOutputStream fos5 = new FileOutputStream(dataloc2);
ObjectOutputStream oos5 = new ObjectOutputStream(fos5);
oos5.writeObject(ObjectVector2);
oos5.flush();
oos5.close();
System.out.println("wrote "+dataloc2);
}
catch(Exception exception)
{
System.out.println("Exception during serialization: " + exception);
System.exit(0);
}
} // end of method
Thanks in advance for your help!