I have a requirement where in I have to create a text file in the sd card and then every time through out the application if I get any exception I have to log it into the text file. Everything should happen in a thread.
At some places, I have a thread running and that gives some exception and in this case how do I start a new thread from this thread to log.
My Questions:
How do I log each and every exception from a new thread.
Can we start a new thread from some other thread.
How do I destroy the thread if I want to use a same thread for writing each and every log to a file although I know it’s not recommended to run a thread more than once.
Is it possible to do this without using log4j.
I suggest you have a dedicated thread with a work queue for your entire application like so:
Then when an exception is caught:
where
LoggingJobcan be something like: