Hi, all

I read the previous message involving the program hang.
And did some testing. My result is that:

       (1) the program of Geoffrey Lowney can work and exit in my machine
(rh7.1 + Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Classic VM (build 1.3.0, J2RE 1.3.0 IBM build cx130-20010329 (JIT enabled:
jitc)))
       (2) The testing program of Andreas cannot exit in my machine. I
don't know whether there is relation between the strange behavior of
onException(JMSException e) method when I do unhappy senarior networking
testing by pulling out the cable. This morning, I try to add
synchronization in the codes of Andreas, but there is a deadlock. 
However, I cannot find
any reason inducing this dead lock. The only reason I suspect is that
when the in.read() method is blocked, it doesn't release the lock.
However, I think it should release its lock at that time because it is a
typical example of the "usage of the conditional variable" in multithread
programming.
       (3) Actually, I am very interested in the TestSocket.java of
Andreas because it cannot exit. So, I changed the codes and test in my
machine and try to make it exit. Finally, it does EXIT.

On the whole, I am very concern about the calling of onException() method.
If there is some relation between the "program hang" and "the calling
problem of onException() ", pls find a solution.

By the way, my onException() problem is that the calling of this method is
strange when I pull out the cable to simulate the unhappy case. It is
never called on linux. But on window98, if I pull out the cable on the JMS
server side, this method will be called, if I pull out the cable of my
machine, this method isn't called and the program hang. Indeed, I am 
confused by
these testings. Probably in the next time, I will get different results.

yangyuexiang



------------------------------------------------------
SwiftMQ developers mailing list * http://www.swiftmq.com
To unsubscribe from this list, send an eMail to 
[EMAIL PROTECTED] and write in the body of your message:
UNSUBSCRIBE developers <your-email-address>
Archive: http://www.mail-archive.com/developers@mail.iit.de/


import java.net.*;
import java.io.*;

public class TestSocket
{
        static InputStream in;
        static int [] lock = new int[1];
        static int [] lable = new int[1];
        
        public static void main(String[] args)
        {
                try {
                        Socket socket = new Socket(args[0],Integer.parseInt(args[1]));
                        socket.setSoTimeout(1500);
                        //socket.setTcpNoDelay(true);
                        in = socket.getInputStream();
                        Thread t = new Thread()
                        {
                                public void run()
                                {
                                try{
                                l:
                                        for (;; Thread.currentThread().sleep(10))
                                        {
                                                try {
                                                        synchronized(lock)
                                                        {
                                                                if(lable !=null)
                                                                {
                                                                        
System.out.println("before read");
                                                                        
try{in.read();}catch(Exception e){}
                                                                        
System.out.println("after read"); 
                                                                }
                                                                else
                                                                        break l;
                                                        }
                                                } catch (Exception e)
                                                {
                                                        e.printStackTrace();
                                                        return;
                                                }
                                        }
                                }catch(Exception ex){}
                                }
                        };
                        t.start();
                        System.out.println("sleeping");
                        Thread.currentThread().sleep(50000);
                        System.out.println("closing socket");
                        synchronized(lock)
                        {
                                System.out.println("------------");
                                socket.close();
                                lable = null;
                        }
                        System.out.println("closing socket done");
                } catch (Exception e)
                {
                        e.printStackTrace();
                        System.exit(-1);
                }
        }
}



------------------------------------------------------
SwiftMQ developers mailing list * http://www.swiftmq.com
To unsubscribe from this list, send an eMail to 
[EMAIL PROTECTED] and write in the body of your message:
UNSUBSCRIBE developers <your-email-address>
Archive: http://www.mail-archive.com/developers@mail.iit.de/


Reply via email to