fork download
  1. public class Zad2a {
  2.  
  3. public static void main(String[] args) throws InterruptedException {
  4. System.out.println("Przed 'i' = " + Test.i);
  5. System.out.println("Przed 'j' = " + Test.j);
  6. new Runnable() {
  7. public void run() {
  8. Test.one();
  9. Test.three();
  10. }
  11. }.run();
  12.  
  13. new Runnable() {
  14. public void run() {
  15. Test.two();
  16. Test.four();
  17. }
  18. }.run();
  19. System.out.println("Po 'i' = " + Test.i);
  20. System.out.println("Po 'j' = " + Test.j);
  21.  
  22. }
  23.  
  24. private static class Test {
  25. private volatile static long i = 0;
  26. static long j = 0;
  27.  
  28. private static void one() {
  29. for (int x = 0; x < 10; x++) {
  30. System.out.println("" + i);
  31. i++;
  32. }
  33. }
  34.  
  35. private static void two() {
  36. for (int x = 0; x < 9; x++) {
  37. System.out.println("" + i);
  38. i--;
  39. }
  40. }
  41. synchronized private static void three() {
  42. for (int x = 0; x < 10; x++) {
  43. System.out.println("" + j);
  44. j++;
  45. }
  46. }
  47. synchronized private static void four() {
  48. for (int x = 0; x < 9; x++) {
  49. System.out.println("" + j);
  50. j--;
  51. }
  52. }
  53.  
  54. }
  55. }
  56.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cs(3,47): error CS1525: Unexpected symbol `throws', expecting `;', `{', or `where'
prog.cs(4,23): error CS1041: Identifier expected, `out' is a keyword
prog.cs(5,23): error CS1041: Identifier expected, `out' is a keyword
prog.cs(7,24): error CS1526: Unexpected symbol `public'
prog.cs(7,42): error CS1525: Unexpected symbol `{'
prog.cs(11,18): error CS1519: Unexpected symbol `.' in class, struct, or interface member declaration
prog.cs(11,19): error CS1520: Class, struct, or interface method must have a return type
prog.cs(13,21): error CS0106: The modifier `new' is not valid for this item
prog.cs(13,21): error CS1520: Class, struct, or interface method must have a return type
prog.cs(14,24): error CS1525: Unexpected symbol `public'
prog.cs(14,32): error CS1547: Keyword `void' cannot be used in this context
prog.cs(14,39): error CS1525: Unexpected symbol `('
prog.cs(18,18): error CS1519: Unexpected symbol `.' in class, struct, or interface member declaration
prog.cs(18,19): error CS1520: Class, struct, or interface method must have a return type
prog.cs(19,26): error CS1519: Unexpected symbol `out' in class, struct, or interface member declaration
prog.cs(19,37): error CS1001: Unexpected symbol `Po 'i' = ', expecting identifier
prog.cs(19,28): error CS1520: Class, struct, or interface method must have a return type
prog.cs(20,26): error CS1519: Unexpected symbol `out' in class, struct, or interface member declaration
prog.cs(20,37): error CS1001: Unexpected symbol `Po 'j' =  ', expecting identifier
prog.cs(20,28): error CS1520: Class, struct, or interface method must have a return type
prog.cs(30,39): error CS1041: Identifier expected, `out' is a keyword
prog.cs(37,39): error CS1041: Identifier expected, `out' is a keyword
prog.cs(41,48): error CS1519: Unexpected symbol `void' in class, struct, or interface member declaration
prog.cs(43,39): error CS1041: Identifier expected, `out' is a keyword
prog.cs(47,48): error CS1519: Unexpected symbol `void' in class, struct, or interface member declaration
prog.cs(49,39): error CS1041: Identifier expected, `out' is a keyword
prog.cs(24,30): error CS1527: Namespace elements cannot be explicitly declared as private, protected or protected internal
prog.cs(55,0): error CS1525: Unexpected symbol `}'
Compilation failed: 28 error(s), 0 warnings
stdout
Standard output is empty