AoInitialize.Shutdown problem

Discussion created by codeconverter on Oct 13, 2011
I have a java application that uses a thread pool to spawn off tasks that the operator requests.  One of these tasks is to bring up ArcMap.  This works fine, a license is obtained using myAoInit = new AoInitialize(); myAoInit.initialize; I load some custom extensions and the operator is free to interact with ArcMap.  The problem I am having is when it comes time to close the application.  The operator selects to close the application and a thread from the thread pool is obtained and it calls myAoInit.Shutdown().  I sometimes then get an interop exception about calling a method on an object that was created in another thread.  If I leave out the call to Shutdown then if the same user tries to relaunch ArcMap it works but if another user tries then they are unable to get a license, i.e. Not calling shutdown does not allow the license to be released even though the ArcMap session has closed.  The thread pool is what is causing me problems but unfortunately my code lives within an infrastructure that would make it difficult for me to keep that same thread that did the initialize alive so that it could also do the shutdown.  Looking for suggestions on other ways to release the license.