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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T06:34:33+00:00 2026-05-26T06:34:33+00:00

I had a quiz for Threads last week and I got these 2 questions

  • 0

I had a quiz for Threads last week and I got these 2 questions wrong. I was wondering if anyone can help me get the right answer for these. Thanks.

Are there any results that CANNOT be the output of this program?
I get confused with these sort of questions. I ran the program and found that Bbccaa is possible, aaccbb is possible, ccbbaa is possible and aabbcc is possible.

public class Test4 extends Thread { //8
  public Test4(String name) { 
   super(name); 
  } 
  public void run() { 
   print(getName()); 
  } 
  public static synchronized void print(String n) { 
   System.out.print(n); 
   try { sleep(...); } catch (Exception ex) {} // unspecified random time 
   System.out.print(n); 
  } 
  public static void main(String argv[]) throws Exception { 
   Test4 ta = new Test4("a"); 
   Test4 tb = new Test4("b"); 
   Test4 tc = new Test4("c"); 
   ta.start(); 
   tb.start(); 
   tc.start(); 
   ta.join(); 
   tb.join(); 
   tc.join(); 
  } 
}

Same question for this code
Abab is possible, baab is possible, baba is possible. I get confused with these sort of questions. Is there any tricks or tips that will help me understand which output is not possible.

public class Test3 extends Thread { 
  public Test3(String name) { 
   super(name); 
  } 
  public void run() { 
   print(getName()); 
  } 
  public static void print(String n) { 
   System.out.print(n); 
   try { sleep(...); } catch (Exception ex) {} 
   System.out.print(n); 
  } 
  public static void main(String argv[]) throws Exception { 
   Test3 ta = new Test3("a"); 
   Test3 tb = new Test3("b"); 
   Test3 tc = new Test3("c"); 
   ta.start(); 
   tb.start(); 
   ta.join(); 
   tb.join(); 
  } 
}
  • 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-26T06:34:34+00:00Added an answer on May 26, 2026 at 6:34 am

    Matthew is right for the first. So it can have anything like aabbcc or ccbbaa as long as it is consecutive, hence the synchronized term.

    The second one I think the code wont print out aacc. Tell me if I am wrong

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

Sidebar

Related Questions

I am having trouble with my game and was wondering if anyone can help?
Here's a few questions I had on a quiz in a class and just
I've got a model setup where a user can create a quiz with many
Had a look over SO but I can't see any threads which address my
Had a good search here but can't see anything that gets my mind in
Had a search around and can't seem to find any options to do this,
Had a question and if anyone has found similar issues. It seems my file
I had a quiz at school and there was this question that I wasn't
Well, I can't seem to solve this XSLT 1.0 take-home quiz problem. Here's the
Had a quick google to see if this can be done without much luck,

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.