Hi Lukasz, I started (later yesterday) using a ThreadLocal Facade object to encapsulate the 'installation' of the remote api, but I like your idea of using a single threaded executor, so I will give it a go.
Thanks, Frank On 11 May 2016 at 17:19, Lukasz Cwik <[email protected]> wrote: > RemoteApiInstaller seems to be unfriendly. > > Have you considered using a single threaded executor > <https://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Executors.html#newSingleThreadExecutor()> > where > you channel all the work you want to do via Callable/Future pairs? > So in start() you would create this single threaded executor, and submit > the first callable to invoke the RemoteApiInstaller.install(...). > In getCurrent()/advance()/... you would channel all your work through the > single threaded executor by giving it callables and blocking on the future > to get the result. > In close() you would submit a task to uninstall the RemoteApi and then you > would shutdown the executor. > > This way you don't have to worry about other peoples installations, can > have multiple variants, and just need to invoke a callable to do work. > Just remember to shutdown the executor to not leak threads. > > > >
