Multi Threading
© examsiri.com
Question : 29 of 44
Marks:
+1,
-0
Given:
We want to guarantee that the output can be either XXYY or YYXX, but never XYXY or any other combination. Which of the following method definitions could be added to theLetters class to make this guarantee? (Choose all that apply.)
public class Letters extends Thread {
  private String name;
  public Letters(String name) { this.name = name; }
  public void write() {
   System.out.print(name);
   System.out.print(name);
  }
  public static void main(String[] args) {
   new Letters("X").start();
   new Letters("Y").start();
  } }We want to guarantee that the output can be either XXYY or YYXX, but never XYXY or any other combination. Which of the following method definitions could be added to theLetters class to make this guarantee? (Choose all that apply.)
Go to Question: