Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8615255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:19:47+00:00 2026-06-12T05:19:47+00:00

I have a requirement where in I have to create a text file in

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:19:48+00:00Added an answer on June 12, 2026 at 5:19 am

    I suggest you have a dedicated thread with a work queue for your entire application like so:

    class Logging {
        public static ExecutorService logger = Executors.newSingleThreadExecutor();
    }
    

    Then when an exception is caught:

    try {
       ...
    } catch(Exception ex) {
       Logging.logger.submit(new LoggingJob(ex));
    }
    

    where LoggingJob can be something like:

    class LoggingJob implements Runnable {
        private Exception ex;
    
        public LoggingJob(Exception ex) {
            this.ex = ex;
        }
    
        public void run() {
            // write ex to log file
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a requirement to create a simple windows forms application that allows an
I have a requirement to create a sysDesk log file. In this requirement I
I have a requirement to create a dynamic table from an xml file similar
I have created a .net application that is currently using a encrypted text file
I have a requirement to create internationalization with regular text files (perhaps simple xml).
I'm using jibx to create a xml. the requirement i have is to get
I am new to Mahout. I have a requirement to convert a text file
I have a requirement to create a xaml page with Semantic Zoom where the
I have a requirement to create a background processor that works only when the
I have a requirement to create a windows form control which has to detect

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.