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

  • Home
  • SEARCH
  • 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 9141443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:38:43+00:00 2026-06-17T09:38:43+00:00

I have an application that runs a background thread which periodically performs a task.

  • 0

I have an application that runs a background thread which periodically performs a task. The UI thread moves through several different activities.

The tutorial I used can be found at this blog, the gist of it is the following:

  • Create a class that extends Thread

public final class JSONThread extends Thread {

  • Define a method in this class that adds a task to the MessageQueue, prompting executing when able.

public synchronized void enqueueJSON(final JSON.JSON task) {

However, after creating the initial object in my main activity, navigating to another activity obviously loses the Object bound to my Thread. I am no longer able to call methods on that Object (hence unable to add to queue).

I am unsure if this is caused by a wrong decision in architecture on my part or by overseeing the obvious solution. Any ideas? Note that I am trying to avoid AsyncTask for this purpose, since a pool of five threads for a simple task seems a little too much.

  • 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-17T09:38:44+00:00Added an answer on June 17, 2026 at 9:38 am

    You need to store a Thread object as member of some other object with lifetime longer than Activity.

    Two ideas for you:

    a) It could be a member of Application (http://developer.android.com/reference/android/app/Application.html)

    You may have problems with this, if you don’t have a Service running. There is no guarantee that your application won’t be killed (as example if any system dialog will pop up on top of your activities)

    b) It could be a member of Service
    (http://developer.android.com/reference/android/app/Service.html)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a GUI application which has a background thread which runs for
Scenario I have a background worker in my application that runs off and does
I have an application that runs through the rounds in a tournament, and I
I have application that runs non stop in the background on a dedicated remote
Background I have an embedded system which runs an application originally written in C++
I have This application that runs it the background well its supposed to. the
I have some image processing code that runs on a background thread and updates
In my java web application, I have a single background-worker thread, which requires a
I have a winform application that runs in background with a BackgroundWorker that has
I have an application that runs on background because it's needs to use Location

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.