/** * Shuts down the database resources held by an instance of this manager if certain conditions are * met. The database resource is released if and only if a client has requested a shutdown * operation and there are no asynchronous operations running. To ensure completeness, this method * is invoked when a client of this manager requests a shutdown and when any asynchronous * operation completes. */ private void maybeShutdownClient() { synchronized (mLock) { if ((mRunningTasks == 0) && mShouldShutdownClient) { LogUtils.log( this, Log.VERBOSE, "All tasks completed and shutdown requested. Releasing database."); mClient.shutdown(); } } }