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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T18:07:19+00:00 2026-05-21T18:07:19+00:00

I am pretty new to Java and the project I have requires a new

  • 0

I am pretty new to Java and the project I have requires a new thread to be created every time the user presses a button. I’ve worked with the MVC and Swing but I am trying to find a way to create however many threads the user needs. I reviewed some information and was trying to use an arrayList to just collect all the threads. However I am having some problems with this:

private ThreadLibrary thread_lib = new ThreadLibrary(); 

    public TestArray(int val) {
        for (int i=0; i < val; i++) {           
            thread_lib.addThread(    new Thread(new runThread()).start()   );       
        }
    }

Since the new operator doesn’t return anything it won’t add anything to the arrayList. Any ideas or a better data structure to use?
Thanks

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

    new definitely returns whatever you’re constructing. It’s the start method which returns void. Try storing the thread object in a variable and kicking it off separately.

    public TestArray(int val) {
        for (int i = 0; i < val; i++) {       
            Thread thread = new Thread(new runThread());
            thread.start();
            thread_lib.addThread(thread);       
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We are using JSF in our project (im pretty new to it) were every
I'm pretty new to Android development, but I have some experience with Java and
I have a project in Java that is pretty much done, except I need
I'm a pretty new C# and .NET developer. I recently created an MMC snapin
I am pretty new to php, but I am learning! I have a simple
I'm pretty new to regular expressions. I have a requirement to replace spaces in
I have written something like this pretty easily in C# ( string GetUrl(new {
I have been working on a Java project in which the reports will be
i m pretty new to Spring MVC, i m trying to setup a page
I have a Java project which I'd like to convert to C#, and after

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.