Questions tagged [background-thread]

A background thread is a thread that not directly driving the application but does some processing asynchronously.

Many UI toolkits require the use of background threads for anything that takes longer than a couple of milliseconds in order to keep the UI responsive.

Background threads are referred to as daemon threads at times.

Often background threads take care of recurring tasks, like cleaning up caches or similar.

Since the term 'background thread' is not very specific you might want to consider more specific tags related to the actual technology you are using.

If your question is independent of the actual technology this tag is a good fit.

Background Thread in .Net
Background thread in java

224 questions
7
votes
3 answers

Best way to create a background thread in java

What is the best way to create a background thread that will run every 15 minutes to get the data from the database? Below is the code I have which will work fine I guess in production but is there any other way better that I have or something that…
arsenal
  • 23,366
  • 85
  • 225
  • 331
5
votes
4 answers

How to update/paint JProgressBar while Swing is loaded building the GUI

I have a GUI which is quite heavy to build/initialize on the platform on which it runs.. Therefore I want to update progress while it initializes.. I have a small undecorated JDialog containing a JLabel and a JProgressBar which I want to update at…
5
votes
3 answers

How to execute a method every second on a background thread so it doesn't affect the performance of the app

I am trying to access my database every 30 seconds, however, whenever the method executes I can clearly see a performance dip in the application. So far this is my current code: var timer = Timer() override func viewDidLoad() { …
James Ajjaja
  • 95
  • 1
  • 5
5
votes
4 answers

What happens if I run an Android thread in the background indefinitely

Android docs indicate that Oreo has new restrictions on background execution: https://developer.android.com/about/versions/oreo/background. This seems reasonable and they're clearly aiming to make their platform more like iOS and prevent apps…
5
votes
3 answers

What happens if an application is closed while a thread of ThreadPool is writing a file?

Suppose you use a ThreadPool to perform some operations and assume that each operation writes on a file. All threads of ThreadPool are background threads, so they will be terminated when closing the application. What happens if the application is…
enzom83
  • 8,080
  • 10
  • 68
  • 114
5
votes
3 answers

NullPointerException in HandlerThread

This bug baffled me for hours. I am getting the NullPointerException. The problem is this error is not consistent. It happens when I launch the app, but only occasionally. So I am not sure what is causing it. I apologize for the verbose question…
5
votes
1 answer

Modal Messagebox from background thread

I've noticed that there seems to be inconsistent behavior as to when a MessageBox is modal. First up, launching a MessageBox from the UI thread. This results in a modal MessageBox, as expected : void MainThreadClick(object sender, RoutedEventArgs…
wforl
  • 843
  • 10
  • 22
4
votes
3 answers

ASP.NET Background Threads

I'm working on an ASP.NET application containing WCF services that is meant to act as a test double for a simulation production environment. It is standing in for a very complicated backend that can receive orders via it's web services and then…
John Mills
  • 10,020
  • 12
  • 74
  • 121
4
votes
1 answer

(iphone) what shouldn't be done in background thread with respect to UIView?

I know and heard most UI related shouldn't be done in thread other than main. I also know that you can update non-view related data member(that you added) of UIView derived class. I wonder if the below operations are fine or not to do in…
eugene
  • 39,839
  • 68
  • 255
  • 489
4
votes
3 answers

android notification not showing from service

I have this service that will connect to the server and fetch notifications but unfortunately it doesn't show any notification this is the service class : public class NotificationService extends Service { @Nullable @Override public…
mr.infin8
  • 53
  • 1
  • 1
  • 5
4
votes
1 answer

Accessing PHPhotoLibrary while app is in the background

I have a NSURLDownloadTask which is successfully downloading files in the background (large image or video files). And I successfully copy url's and call this function to save my url to photo library. As you can see, I would like to send a…
NSGangster
  • 2,397
  • 12
  • 22
4
votes
1 answer

Magical Record - fetch in main thread block ui, in background return nil

I'm new to Magical Record, but already have seen a few questions on stackoverflow, and can't find an answer to my question. I have to find items with the predicate using this type of construction: NSArray *result = [MOSomeItems…
yarchiko
  • 43
  • 1
  • 3
4
votes
1 answer

Need help running thread SBCL

I am working some lisp code on sbcl in order to run function in mode daemon. The problem is when I use the function sb-thred:make-thread, for instance as follow: (sb-thread:make-thread (lambda () (progn (sleep 1) (when t (print "background…
yannics
  • 179
  • 10
4
votes
1 answer

Schedule a task every day using ScheduledExecutorService?

I am using ScheduledExecutorService to run a particular task at 3 AM in the morning everyday. Now I am not sure whether my below code will call MyTask() every 3 AM in the morning? As I am not sure whether my logic is right or…
user2467545
4
votes
2 answers

IOS background work

I have an iPhone application like facebook for iPhone. My application must connect my server and read all message every two hours regularly. I have a thread to read all message but when the application is terminated the thread cannot work. Can the…
1
2
3
14 15