多線程Socket通信問題
現在在做一個多線程Socket通信問題﹐現在在接受數據端老是過2到3個小時就有一條線程死掉﹐例外還有兩個類一個是界面啟動線程的﹐一個是對接收數據處理﹐這段程試是兩個死循環﹐外循環是不斷監聽是否有數據傳過來﹐內循環是在數據庫里搜索數據什么處理完并返回信息。望高手能給我點意見﹐不勝感激﹗
public void run()
{
try
{
String readMess= " ";
client=null;
in=null;
out=null;
client =new Socket(ip,port);
//client =new Socket( "10.242.10.75 ",4660);
System.out.println(line+ " CONNECTION OK! ");
out = new DataOutputStream(client.getOutputStream());
in = new DataInputStream(client.getInputStream());
flag=true;
while(true)
{
System.out.print(line);
System.out.println(client.isConnected());
readMess=in.readLine().trim();
if(readMess.equals( " ")||readMess==null)
{
System.out.println( "while end! ");
break;
}
else
{
id=trans.getID(readMess);
strData=trans.getData(readMess);
insert_RCV_Data(strData,id);
int count=0;
while(true)
{
int getflag=get_send_flag(id);
if(getflag==0)
{
sleep(150);
count++;
if(count==20)
{