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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:37:50+00:00 2026-05-27T06:37:50+00:00

I have an app that reads about 3-5 rss feeds and present the headlines

  • 0

I have an app that reads about 3-5 rss feeds and present the headlines on the UI. I’ve put the reading code inside an asynctask to keep the UI responsive. But my code reads the feeds one at a time and I would like to read the 3 rss feeds at the same to see if I can speed up the parsing process and present the headlines faster on the UI.

I’ve tried to use threads – but then I ran into the problem that I didn’t knew which thread would finish first, second and last and.. well, I just couldn’t figure out how to check when the slowest thread had finished so I could sort the rss news objects by date and time. So eventually I tried to use asynctask reading the feeds one at a time like this:

class ReadFeedsTask extends AsyncTask<Void, String, Void> {
@Override
protected Void doInBackground(Void... unused) {

    try {

        URL url = new URL("http://www.fyens.dk/rss/sport");
        HttpURLConnection conn = (HttpURLConnection) url.openConnection();

        if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
            InputStream is = conn.getInputStream();

            DocumentBuilderFactory dbf = DocumentBuilderFactory
                    .newInstance();
            DocumentBuilder db = dbf.newDocumentBuilder();
            Document document = db.parse(is);
            Element element = document.getDocumentElement();

            NodeList nodeList = element.getElementsByTagName("item");

            if (nodeList.getLength() > 0) {
                for (int i = 0; i < nodeList.getLength(); i++) {

                    Element entry = (Element) nodeList.item(i);

                    Element _titleE = (Element) entry.getElementsByTagName(
                            "title").item(0);
                    Element _descriptionE = (Element) entry
                            .getElementsByTagName("description").item(0);
                    Element _pubDateE = (Element) entry
                            .getElementsByTagName("pubDate").item(0);
                    Element _linkE = (Element) entry.getElementsByTagName(
                            "link").item(0);

                    String _title = _titleE.getFirstChild().getNodeValue();
                    String _description = _descriptionE.getFirstChild().getNodeValue();
                    Date _pubDate = new Date(_pubDateE.getFirstChild().getNodeValue());
                    String _link = _linkE.getFirstChild().getNodeValue();

etc..

and then I repeat this process for the other rss feeds.

How can I use this code to read multiple feeds at the same time – if not by using asynctasc then by using threads? My problem is that I’m not able to understand how to wait untill all threads have finished so I can sort the results and present the newest first?

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

    My thought process would be something like this:

    1. Create a list of all the feeds.
    2. From 1 to max number of threads, spawn a new thread to retrieve the data from the feed
    3. As a thread completes, checks list for remaining feeds to check; if more remain, remove feed from list and retrieve the data from the feed
    4. Each thread, once completed, adds the data for its retrieved feed to whatever data source you’re using for the list adapter, sorts the data source, and notifies the list that the data set has changed.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have successfully created an app that reads from a bundled .plist file and
I have an HTML (App) file that reads another HTML (data) file via jQuery.ajax()
What I have is a C# windows app that reads a bunch of SQL
Help me, Stackoverflow! I have a simple .NET 3.5 console app that reads some
I have a C# console app App1 that reads a row of data from
I have a Rails app that has 2 clients -- an iOS app reads/writes
I have a simple app that reads internet resource and displays the information in
I have a .NET console app that reads info from a USB stick and
I have a windows service that reads from app.config. I want some settings to
I have an app that has a bunch of resources. Having read about javascript

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.