views:

291

answers:

1

I have this somewhat unusual process structure:

  1. Launch4J starts my Java application. It creates a mutex to provide single-instance functionality.
  2. The Java application starts a VB6 application.
  3. When the Java application terminates, the VB6 application is still running. (Desired behaviour)

The problem is: The mutex created by Launch4J is only released after the VB6 application terminates. Because of that it's impossible to start the Java application again.

Why would this happen? I'm not opening the mutex explictly...

I first suspected it is because of Java using CreateProcess with bInheritHandles == true, but the problem does not occour when I start notepad.exe for example.

EDIT: I still have this problem. Any pointers are appreciated!

+1  A: 

Does Launch4J release the mutex and close its handle before terminating? I'm sorry, but I don't know how Java wraps the OS Mutex functions, but you should ensure you explicitly release the mutex and close its handle before your thread ends.

pipTheGeek
Launch4J creates a native Win32 wrapper, so it's not really Java related. Yes, the mutex reference count decreases as soon as the Java app terminates.
DR
Sorry, I wasn't suggesting the problem was Java related, just apologising for not being able to tell you which methods to call.There is a difference between the Mutux reference count decrementing becuase it has been abandoned or becuase it has been released correctly, it is that difference I was trying to point out.
pipTheGeek