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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T06:04:20+00:00 2026-05-20T06:04:20+00:00

My application makes its web service calls from an IntentService. Each Intent is effectively

  • 0

My application makes its web service calls from an IntentService. Each Intent is effectively a web service call that needs to take place.

As you know, an IntentService queues Intents; so only 1 web service call will be taking place at any given time. This is actually desired behavior.

However, this does present a problem. Suppose my app queues up 5 Intents in this IntentService. Say the user ends up on a screen that maybe holds up the UI while some data is retrieved from a web service. If the Intent for this web service is put on the back of the queue, it could be a long while before the web service is called, holding the user up for an unacceptable amount of time.

Since I can’t inject Intents to the front of an IntentService’s queue (as far as I know), I’ve decided to create a second IntentService for calls that require immediate execution. Since I only want 1 call hitting my services at any given time, I’ve wrapped a mutex around the actual Http code. So, in this case, the Intent would execute right away (because it’s in a different IntentService), but loop on the mutex until whatever call in the other IntentService is finished.

This works good for me; I’m fine with all of it.

Here is my question:

Theoretically, the new IntentService could queue up, too. Because of the application workflow, this is unlikely to happen, but it’s theoretically possible. If this is the case, I’d like the new IntentService to finish before the original IntentService resumes again. My idea for doing this is locking/unlocking a new mutex in the create and destroy methods of the new IntentService. The same mutex will also be locked/unlocked at the beginning and end of the onHandleIntent method of the old IntentService. However, I’m concerned about what ramifications locking a mutex in the create of an IntentService will have, holding up its creation (presumably, super.create will be called before the lock). Will Intents still be able to queue up? Are there any other pitfalls to doing this?

  • 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-20T06:04:20+00:00Added an answer on May 20, 2026 at 6:04 am

    Since I can’t inject Intents to the front of an IntentService’s queue (as far as I know)

    Not with the standard implementation. However, IntentService is not a big class. You could clone it and replace the Handler-based system it uses today with a PriorityBlockingQueue.

    Are there any other pitfalls to doing this?

    Besides it scaring the crap out of me, in terms of possible deadlocks?

    You might look at ReentrantReadWriteLock or something along those lines, instead of the Mutex pair. While technically yours is not a “read” vs. “write” scenario, you can think of “read” and “write” as simply being two priorities. There are ways to configure such a lock to favor “writes”, so your 2nd IntentService would be the “write” and your 1st IntentService would be the “read”.

    But I’d really look to replace IntentService with a workalike that has the characteristics you seek, rather than trying to get two IntentServices to work together.

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

Sidebar

Related Questions

I have a web application that makes heavy use of the Session state to
I have a VB web application that reads from a CSV file which contains
When a PHP application makes a database connection it of course generally needs to
We have a Linux application that makes use of OpenSSL's Python bindings and I
I have a PHP application that makes extensive use of Javascript on the client
I've recently inherited an application that makes very heavy use of session, including storing
I've got the following situation A rails application that makes use of rjs /
I a have a multithread application (MIDAS) that makes uses of windows messages to
Spring.NET is an open source application framework that makes building enterprise .NET applications easier.
I have a java application that will take the image as an input and

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.