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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T01:48:17+00:00 2026-05-16T01:48:17+00:00

The threads should start at same split second. I understand, if you do thread1.start()

  • 0

The threads should start at same split second. I understand, if you do thread1.start(), it will take some milliseconds before the next execution of thread2.start().

Is it even possible or impossible?

  • 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-16T01:48:17+00:00Added an answer on May 16, 2026 at 1:48 am

    To start the threads at exactly the same time (at least as good as possible), you can use a CyclicBarrier:

    // We want to start just 2 threads at the same time, but let's control that 
    // timing from the main thread. That's why we have 3 "parties" instead of 2.
    final CyclicBarrier gate = new CyclicBarrier(3);
    
    Thread t1 = new Thread(){
        public void run(){
            gate.await();
            //do stuff    
        }};
    Thread t2 = new Thread(){
        public void run(){
            gate.await();
            //do stuff    
        }};
    
    t1.start();
    t2.start();
    
    // At this point, t1 and t2 are blocking on the gate. 
    // Since we gave "3" as the argument, gate is not opened yet.
    // Now if we block on the gate from the main thread, it will open
    // and all threads will start to do stuff!
    
    gate.await();
    System.out.println("all threads started");
    

    This doesn’t have to be a CyclicBarrier, you could also use a CountDownLatch or even a lock.

    This still can’t make sure that they are started exactly at the same time on standard JVMs, but you can get pretty close. Getting pretty close is still useful when you do for example performance tests. E.g., if you are trying to measure throughput of a data structure with different number of threads hitting it, you want to use this kind of construct to get the most accurate result possible.

    On other platforms, starting threads exactly can be a very valid requirement btw.

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

Sidebar

Ask A Question

Stats

  • Questions 498k
  • Answers 498k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I've found it since then. Basically, yes, pdflush and write… May 16, 2026 at 12:26 pm
  • Editorial Team
    Editorial Team added an answer As bjynito said, you want to look at the SDK,… May 16, 2026 at 12:26 pm
  • Editorial Team
    Editorial Team added an answer Your problem might be, since you use the original image,… May 16, 2026 at 12:26 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I'm running a C# Console Application that is multi-threaded. The core process retrieves some
I have a server application that uses a lot of threads. Without wanting to
I need to create two (or more) WPF windows from the same process. But
I have two threads running from a controller class. The first thread receives SMS
I have an application that has multiple threads processing work from a todo queue.
I recently benchmarked the .NET 4 garbage collector, allocating intensively from several threads. When
Is it safe to start a thread pool in an objects constructor? I know
I need to send messages to the GUI thread which should be processed the
Joshua Bloch's Effective Java, Item 51 is not about depending on the thread scheduler
I am chaining together 15 async operations through ports and receivers. This has left

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.