tough nut this!
im making a chat application thru java and my teacher too seems to be at a loss at this one.
here, one thread in my server is used for reading objects(to/from/message/etc) from the client stream. i have made a vector of the input streams of the clients and am going thru the whole vector once in a for loop, every time the loop is executed.
now, if the server does not recieve any object from a particular client, will the execution stall at the 'readObject' line...or will the next element of the vector be accessed?
i cannot force the for loop...coz the line after readObject may never be accessed! so could it be that Thread.sleep statment is never reached and it hangs?
i include a part of the code...
mport java.io.*;
import java.net.*;
import java.util.*;
public class sendinfo extends Thread
{
String s1="null";
String s2="all";
val2 data2;
val data3;
ObjectInputStream in;
ObjectOutputStream out;
information i;
Enumeration enum;
public sendinfo(Vector en)
{enum=en.elements();
this.start();
}
public void run()
{
for(;;)
{
while(enum.hasMoreElements())
{
i=new information();
i=(information)enum.nextElement();
in=(ObjectInputStream)i.is;
try
{
if ((data2=(val2)in.readObject())==null)continue;
else doneedful(data2);
}
catch(IOException e){}
catch(ClassNotFoundException t){}
}
try{
Thread.sleep(500);
}
catch(InterruptedException g){}
}
}
public void doneedful(val2 data2)
{//code
}
and so on.....

