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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:32:27+00:00 2026-05-30T12:32:27+00:00

I am using ExecutorService to run parallel junit tests. Each test uses a random

  • 0

I am using ExecutorService to run parallel junit tests. Each test uses a random number generator to identify itself and run independent of the other tests. My scenario is like this

  • Test 1 Add new users into the system
  • Test 2 Search for users with certain characteristics in the system
  • Test 2.1 Select one of the searched users, and send a request
  • Test 3 Now use identity from Test 1, and check if there is a request pending. But this test cannot run until 1 and 2 have run. Also they need some data from test1.

I know I can use public static variables to save and restore the data from test1. Any ideas on doing this neatly. Dont want to create a bad impression 1st day at work.

Sample Code below

public class TestCases {
    static ExecutorService exe ;
    public static void main(String[] args) throws Throwable {
        test1() ;
        test2() ;
        test3() ;
    }

   public static void test1() {
       exe = Executors.newCachedThreadPool() ;
       for (int i = 0 ; i < 10 ; i++) {
           Test1 test1 = new Test1() ;
           exe.execute(test1) ;
        }
        exe.shutdown() ;
        while(!exe.isShutDown()) {
        }
    }
    //same for test2 and test3
}
  • 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-30T12:32:28+00:00Added an answer on May 30, 2026 at 12:32 pm

    One way to do this would be to merge Test1 and Test2 as a subset of Test3. Infact all these together can be a Test4. This way you will be testing only 1 particular scenario. I suggest that you think in a way to create scenario based testing.

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

Sidebar

Related Questions

I am using an ExecutorService (a ThreadPoolExecutor) to run (and queue) a lot of
say I'm using a ExecutorService ex = Executors.newFixedThreadPool(nrofthreads); spinning up some work and waiting
I'm firing off tasks using an ExecutorService, dispatching tasks that need to be grouped
I'm using a java.util.concurrent.ExecutorService that I obtained by calling Executors.newSingleThreadExecutor() . This ExecutorService can
I am using a ThreadPool via ExecutorService. By calling shutDownNow() it interrupts all running
I am executing a Callable Object using ExecutorService thread pool. I want to give
I have a local scientific application that uses threads to process independent pieces of
I wrote an application that runs some threads using ExecutorService and waits until they
One of actions in Struts2 is using below code: java.util.concurrent.ExecutorService myservice = Executors.newSingleThreadExecutor(); myservice.execute(new
I am trying to run multiple threads concurrently, where each thread is computing value

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.