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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:30:45+00:00 2026-06-12T14:30:45+00:00

i am trying to write a java programm that is reading informations out of

  • 0

i am trying to write a java programm that is reading informations out of a database and creates for every row of the table a new thread. So i dont know how much threads i will need. so far i have this:

        con = DriverManager.getConnection(url, user, passwd);
        pst = con.prepareStatement("select hostname, ipadress, vncpassword from infoscreens");
        rs = pst.executeQuery();
        int i=0;
        while (rs.next()) {
            i++;
            Thread tread[i]  = new Savescreenshots(rs.getString(1),rs.getString(3),rs.getString(2));
            tread[i].start();
        }

but the problem is that this isnt working. i need a possibility to create for each row in the table a new thread. dose anyone have an idea how to do that

thanks and greetings

  • 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-12T14:30:46+00:00Added an answer on June 12, 2026 at 2:30 pm

    You need a dynamically growing container for a set of unknown size – a List, for example:

    List<Thread> threads = new ArrayList<Thread>();
    while (rs.next()) {
        Thread tread  = new Savescreenshots(rs.getString(1),rs.getString(3),rs.getString(2));
        tread.start();
        threads.add(thread);
    }
    

    At this point, all Thread objects that your program created and started are elements of the threads list. You can enumerate them and do whatever else you were planning to do with them (e.g. wait for them to finish):

    for (Thread thread : threads) {
        thread.join();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to java and am trying to write a simple program that basicly
I am trying at write a java program that hits a url over ssl,
I am trying to write a Java program that reads an input file consisting
I'm trying to follow Java's JDBC tutorials to write a Java program that can
I'm trying to write a program in Java that uses osql to generate a
I'm trying to write a program in Java that looks for patterns of strings
I'm trying to write a java program to connect to the same MySQL database
I am trying to write a java program that will automatically download and name
I am new to java and netbeans. I am trying to write a program
Guys I'm a bit new in using java and i'm trying to write a

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.