class BgThread extends Thread {
    // Create a logger. For more information on the logging api's,
    // see The Quintessential Logging Program
    Logger logger = Logger.getLogger("com.mycompany.mypackage");

    BgThread() {
        // As a daemon thread, this thread won't prevent the application from exiting

    // Set to true to shut down this thread
    boolean stop = false;

    public void run() {
        while (!stop) {
            try {
                // Perform work here
            } catch (Throwable t) {
                // Log the exception and continue
                logger.log(Level.SEVERE, "Unexception exception", t);

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.