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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:07:14+00:00 2026-05-20T21:07:14+00:00

I have tried to do this with simple Threads and succeded but I believe

  • 0

I have tried to do this with simple Threads and succeded but I believe that using Threadpool I could do the same thing more effeciently:)?
simple threads:

public static class getLogFile implements Runnable {
    private String file;

    public void setFilename(String namefile){
    file=namefile;
    }
    public int run1(String Filenamet) {

    connectToServer(XXX, Filenamet, XXX, XXX, XXX, XXX);//creates a file and downloads it

        return 0;
    }

    public void run() {
            run1(file);
    }

}

in main:
for(x=0 ; x < 36 ; x++){
    String Filename1=Filename+x;
    getLogFile n=new getLogFile();
    n.setFilename(Filename1);
    (new Thread(n)).start();

}

Program connects to the server executes 36 commands(using threadpool/simplethreads?!) at the same time and either downloads 36 result files, than merges them, or maybe it could just write to one file on server and then download it?

  1. how to transform this code into threadpools?
  2. how to write data to one file from 36 threads?
  • 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-20T21:07:14+00:00Added an answer on May 20, 2026 at 9:07 pm

    I can only offer you directions.

    In order to use thread pool, look how ServiceExecutor works. Any example from Google will give you enough information. As an example look at:
    http://www.deitel.com/articles/java_tutorials/20051126/JavaMultithreading_Tutorial_Part4.html

    Concerning writing 36 threads to its own file, or writing into the one file. I cannot say anything about writing by several threads into the same file, but you may use CyclicBarrier to wait event when all threads will finish writing. Example of its using you may find here:
    http://download.oracle.com/javase/1.5.0/docs/api/java/util/concurrent/CyclicBarrier.html

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

Sidebar

Related Questions

I have started using Simple-form and Bootstrap and I have tried to follow this
This should be really simple, but I have tried many solutions posted on the
I have tried this... Dim myMatches As String() = System.Text.RegularExpressions.Regex.Split(postRow.Item(Post), \b\#\b) But it is
I have tried this but it does not work (even if I specify .wav
i have tried this code to redirect a php page.but it s not working
I have tried this but it doesn't work: tell application Preview set myfile to
I have this c++ program that is doing a simple ping on a specified
This may be a really simple question, but things I've tried don't seem to
I have searched a lot of threads but i can't find any answer that
I have a Simple Multithread Server, the code of Threads looks like this: public

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.