Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4147067

native threads: Thread( runnable ) where runnable opens server socket hangs

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.1.6
    • core-libs
    • sparc
    • solaris_2.6



      Name: diC59631 Date: 06/09/98


      works with green threads, hangs with native threads

      import java.net.*;
      public class NativeThreadsTest
        {
        ServerSocket server;
        public static void main( String[] args )
          {
          try
            {
            NativeThreadsTest test = new NativeThreadsTest();
            test.startup();
            test.shutdown();
            }
          catch( Exception e )
            {
            e.printStackTrace();
            }
          }
        void startup() throws Exception
          {
          server = new ServerSocket( 8000 );
          Thread thread = new Thread( new Acceptor( server ) );
          thread.start();
          }
        void shutdown() throws Exception
          {
          System.out.println( "Shutting down server" );
          server.close();
          System.out.println( "Ending" );
          }
        }
      ----------------------------------------------------------------
      import java.net.*;
      public class Acceptor implements Runnable
        {
        ServerSocket server;
        public Acceptor( ServerSocket socket )
          {
          server = socket;
          }
        public void run()
          {
          try
            {
            System.out.println( "Accepting socket info" );
            server.accept();
            }
          catch( Exception e )
            {
            }
          }
        }
      (Review ID: 33160)
      ======================================================================

            alanb Alan Bateman
            dindrigo Daniel Indrigo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: