1

I have a Java application running on both Mac and Windows. I call System.exit(0) on user pressing "exit" button. The application works well on Win7. But on Mac, after I press "exit" button, the program can not exit. There is no response from the application.

According to the Activity Monitor, all user threads are terminated. I don't know what the program is waiting for.

I could't paste the whole output of Activity Monitor, but here is an example:

851 Thread_435381: Java: Exception Handler Thread  
851 Thread_435386: Java: Gang worker#0 (Parallel GC Threads)
851 Thread_435493
851 thread_start  (in libsystem_c.dylib) + 34  [0x92abd6de]  
851 _pthread_start  (in libsystem_c.dylib) + 335  [0x92ab9ed9]  
851 CAPThread::Entry(CAPThread*)  (in CoreMediaIO) + 123  [0x9a5e3a3d]  
851 CMIO::DAL::RunLoop::OwnThread(void*)  (in CoreMediaIO) + 160  [0x9a5eded2]  
851 CFRunLoopRunInMode  (in CoreFoundation) + 120  [0x9329c328]  
851 CFRunLoopRunSpecific  (in CoreFoundation) + 332  [0x9329c47c]  
851 __CFRunLoopRun  (in CoreFoundation) + 1428  [0x9329cda4]  
851 __CFRunLoopServiceMachPort  (in CoreFoundation) + 170  [0x93293c7a]  
851 mach_msg  (in libsystem_kernel.dylib) + 70  [0x942601f6]  
851 mach_msg_trap  (in libsystem_kernel.dylib) + 10  [0x94260c22]'  
1
  • Sounds like a bug as System.exit() should trigger a shutdown (or not) on all systems. Which version of Java and version of the OS do you have? Commented Jul 31, 2012 at 7:26

3 Answers 3

1

1. I think you are mixing your Non-Gui work with the Gui.

2. I hope you have kept your Event Dispatcher Thread only for GUI purpose and nothing else, if you havent try this..and then try to do it...

public static void main(String[] args){

        EventQueue.invokeLater(new Runnable(){

               public void run(){


                      myframe.setVisible();

                   }


          });


   }
Sign up to request clarification or add additional context in comments.

Comments

0

I think you are using swing JFrame, in addition to Kumar Vivek Mitra's answer, to exit, you can also do this:

jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

Comments

0

Make a Thread Dump to see which threads are blocking exit. To do so, open a command prompt, and do ps -eaf | grep java. Find your pid and do , kill -3 3 times.

You should get a Thread dump and see which thread is blocking. REgards Philippe

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.