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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T21:56:33+00:00 2026-06-17T21:56:33+00:00

while we want to execute 2 Runnable s : executor.execute(new Runnable1()); executor.execute(new Runnable2()); it

  • 0

while we want to execute 2 Runnables :

executor.execute(new Runnable1());
executor.execute(new Runnable2());

it is unknown that which Runnable will start to be executed first? but I want Runnable1 be started for execution first. how to do that?

  • 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-17T21:56:34+00:00Added an answer on June 17, 2026 at 9:56 pm

    Why not create one runnable which just runs Runnable1() then Runnable2()? If you don’t want them to execute in parallel, don’t submit them both to an executor separately…

    For example:

    executor.execute(new Runnable() {
        @Override public void run() {
            new Runnable1().run();
            new Runnable2().run();
        }
    });
    

    Of course, you should consider what you want to happen if Runnable1 throws an unchecked exception – do you want Runnable2 to run or not?

    EDIT: With your updated requirements, it sounds like really you want your second runnable to only start when your first runnable has reached a particular point (e.g. a socket has been created and is listening for connections). You quite possibly want to put some sort of hook in that code, so that you can start the second runnable when you get there:

    // Somewhat pseudo-code...
    Server server = new Server();
    server.onStartedListening(new Runnable() {
        @Override public void run() {
            executor.execute(new ClientConnection());
        }
    });
    executor.execute(server);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to have a task that will execute every 5 minutes, but it
i have a character controller which jumps but while jumping i want to change
I want to set timeouts for threads which are executed within a thread pool.
I want to execute the following query using Subsonic: SELECT MAX([restore_date]) FROM [msdb].[dbo].[restorehistory] While
I have a page that I want to execute via cron. It just does
I have a shortcut/bookmark app that links to a website. I want to execute
I have a situation where I have a callback that I want to execute
I want to execute my app at login items(When OS X Starts up). While
I want to execute a script after the whole page has loaded, when it's
I've been looking for a while and want a way to sort a 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.