fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class StreamOne extends Thread{
  8. @Override
  9. public void run(){
  10. while(true){
  11. try{
  12. sleep(5000);
  13. System.out.println("Работаю!");
  14. }
  15. }
  16. }
  17. class StreamSecond extends Thread{
  18. @Override
  19. public void run(){
  20. while(true){
  21. Scanner scn=new Scanner(System.in);
  22. System.out.println("Введите а:");
  23. int a=scn.nextInt();
  24. System.out.println("Введите b:");
  25. int b= scn.nextInt();
  26. System.out.println("Ответ:"+(a+b));
  27. }
  28. }
  29. /* Name of the class has to be "Main" only if the class is public. */
  30. class Ideone
  31. {
  32. public static void main (String[] args) throws java.lang.Exception
  33. {
  34. StreamOne stream=new StreamOne();
  35. stream.start();
  36. StreamSecond streamsec=new StreamSecond();
  37. streamsec.start();
  38. }
  39. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:40: error: reached end of file while parsing
}
 ^
1 error
stdout
Standard output is empty