In my android Application I've got a specific method in one of my MODEL classes and this method always gets called from a separate thread other than UI thread.
The AlarmManger periodically runs this method and also user have the option to run this method from UI. (AlarmManger operation and UI operation call this method from a separate thread other than Main application UI thread).
I just do NOT want to allow to run this method same time from UI and AlarmManger.
Of course I can Synchronise this method and that guarantees one thread execute method at ones. But that's NOT what I want.
I want to throw an exception and stop the second thread (could be UI call or AlarmManager depending on situation) if one already executing the method. So I can inform user that operation cancelled as another running instance (AlarmManger or form UI) was Found.
Can I ask what the best approach for a situation like this. Thanks