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 6332755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T18:20:47+00:00 2026-05-24T18:20:47+00:00

I have strictly separated the layers between different parts of my Android application. At

  • 0

I have strictly separated the layers between different parts of my Android application.
At some point of execution I am updating my data from xml service on Internet. That updating takes up about 10 seconds and is done completely in the background – meaning the user interface of an application works fine. However further calls to my class (later – DataManager) which is responsible for data updating (after update has been started but not yet finished) makes my application crash. NullPointerException is thrown with objects which NEVER are null.

So I assume that only one Thread can use my DataManager at one time and calls to DataManager from other threads ends up in exceptions.

I tried various combinations of putting ‘synchronized’ keywords near sensitive methods but it seems that when update is executing – NOTHING can use ANYTHING from my DataManager.

BTW other classes which are related to DataManager during the execution also seem to hold null objects.

I guess I am just missing some kind of design pattern which is used to deal with concurrency problems and maybe anyone can suggest me something?

  • 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-05-24T18:20:48+00:00Added an answer on May 24, 2026 at 6:20 pm

    I had trouble dealing with using the Apache http client because of threading issues and I think your issue could be similar in that respect. What I ended up doing was setting up a callback scheme. This may or may not work for you, of course.

    This may seem a bit Rube Goldberg-like to you, but it worked for me.

    I would have my UI thread call my data manager object with a method that spawned a thread to go and acquire the data. The method’s return value is an object that would EVENTUALLY have the data in it. I would have my activity extend an interface, something like “DataCallbackInterface”, with a method that the thread would call after it acquired the data (i.e. the last line in run()). Since that call will inherently be within another thread, you’ll need to use a Handler to run anything useful in your implementation of the DataCallbackInterface method. When that method is called, you will know for a fact that the data is there and not rely on any strange synchronization flags to get it right.

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

Sidebar

Related Questions

I have some old C# plugin code that was implemented strictly with Reflection. In
We have some PL/pgSQL stored procedures in our DB (PostgreSQL 9.x). These are strictly
I have a SQL Server that holds a lot of data. An application, running
I have data objects with methods for loading, saving, updating data. Then I have
I have some basic questions about core data (which I am new to) and
If you have a set of tables in the database that strictly consist of
Have deployed numerous report parts which reference the same view however one of them
(Not strictly programming, but a question that programmers need answered.) I have a benchmark,
We have recently compared the respective file sizes of the same tabular data (think
We have strictly defined which relationships are CascadeType.MERGE in our app. This plays into

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.