Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // var. 2361
- public class Lab4 {
- public static void main(String[] args) {
- C a = new C();
- C b = new E();
- E c = new E();
- a.z42();
- b.z36();
- c.z27();
- c.z3();
- b.z9();
- b.z40();
- c.z32();
- a.z18();
- a.z10();
- c.z31();
- b.z24(a);
- a.z24(b);
- a.z24(c);
- c.z15();
- c.z38();
- c.z23();
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(true) {
- try {
- E d = new E();
- d.z47();
- Thread.sleep(9);
- } catch(Exception e) {
- // Do nothing
- }
- }
- }
- });
- t.start();
- }
- }
- class C {
- int z21;
- int z5;
- int z44;
- int z16;
- int z4;
- long z14;
- long z22;
- long z45;
- java.io.ObjectOutputStream printOutput;
- java.io.ObjectOutputStream fileWrtr;
- int[] z7 = {3, -1, -1, -2};
- int[] z2 = {-1, 1, 1, 2, 3};
- int[] z41 = {-2, 3, 1, 0};
- static java.util.Map<java.net.URL,byte[]> cache = new java.util.HashMap<>();
- static int z13;
- static int z34;
- static int z48;
- static int z17;
- static int z50;
- java.util.List<String> z20 = new java.util.ArrayList<>();
- java.util.List<String> z6 = new java.util.ArrayList<>();
- java.util.List<String> z43 = new java.util.ArrayList<>();
- public C() {
- z21 = 2;
- z5 = 0;
- z44 = 1;
- z16 = 1;
- z4 = 1;
- z14 = 5L;
- z22 = 6L;
- z45 = 5L;
- try {
- printOutput = new java.io.ObjectOutputStream(new java.io.FileOutputStream("printOutput.txt"));
- fileWrtr = new java.io.ObjectOutputStream(new java.io.FileOutputStream("fileWrtr.txt"));
- } catch (java.lang.Exception e) {
- // Do nothing
- }
- }
- public void init() {
- try {
- if (printOutput == null) printOutput = new java.io.ObjectOutputStream(new java.io.FileOutputStream("printOutput.txt"));
- System.out.println("Thread : " + Thread.currentThread() + ", printOutput = " + printOutput);
- } catch(Exception e) {
- // Ignore it
- }
- try {
- if (fileWrtr == null) fileWrtr = new java.io.ObjectOutputStream(new java.io.FileOutputStream("fileWrtr.txt"));
- System.out.println("Thread : " + Thread.currentThread() + ", fileWrtr = " + fileWrtr);
- } catch(Exception e) {
- // Ignore it
- }
- }
- public byte[] getValueFromCache(String s) {
- try {
- java.net.URL url = new java.net.URL(s);
- if(!cache.containsKey(url)) {
- cache.put(url, new byte[1572864]);
- }
- return cache.get(url);
- } catch (Exception e) {
- System.out.println("Error: invalid URL!");
- return null;
- }
- }
- public void z42() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- init();
- int i = 0;
- while(true) {
- i++;
- try {
- synchronized(fileWrtr) {
- fileWrtr.writeObject("метод z42 в классе C (#" + String.valueOf(i) + ")");
- Thread.sleep(6);
- fileWrtr.flush();
- fileWrtr.reset();
- }
- } catch(Exception e) {
- // Do nothing
- }
- }
- }
- });
- t.start();
- }
- public void z36() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- init();
- int i = 0;
- while(true) {
- i++;
- try {
- synchronized(printOutput) {
- printOutput.writeObject("метод z36 в классе C (#" + String.valueOf(i) + ")");
- Thread.sleep(5);
- printOutput.reset();
- }
- } catch(Exception e) {
- // Do nothing
- }
- }
- }
- });
- t.start();
- }
- public void z27() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- init();
- int i = 0;
- while(true) {
- i++;
- try {
- synchronized(fileWrtr) {
- fileWrtr.writeObject("метод z27 в классе C (#" + String.valueOf(i) + ")");
- Thread.sleep(5);
- fileWrtr.flush();
- fileWrtr.reset();
- }
- } catch(Exception e) {
- // Do nothing
- }
- }
- }
- });
- t.start();
- }
- public void z3() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- init();
- int i = 0;
- while(true) {
- i++;
- try {
- synchronized(printOutput) {
- printOutput.writeObject("метод z3 в классе C (#" + String.valueOf(i) + ")");
- Thread.sleep(6);
- printOutput.flush();
- printOutput.reset();
- }
- } catch(Exception e) {
- // Do nothing
- }
- }
- }
- });
- t.start();
- }
- public void z9() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- init();
- int i = 0;
- while(true) {
- i++;
- try {
- synchronized(printOutput) {
- printOutput.writeObject("метод z9 в классе C (#" + String.valueOf(i) + ")");
- Thread.sleep(6);
- printOutput.reset();
- }
- } catch(Exception e) {
- // Do nothing
- }
- }
- }
- });
- t.start();
- }
- public void z40() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- init();
- int i = 0;
- while(true) {
- i++;
- try {
- synchronized(printOutput) {
- printOutput.writeObject("метод z40 в классе C (#" + String.valueOf(i) + ")");
- Thread.sleep(5);
- printOutput.flush();
- printOutput.reset();
- }
- } catch(Exception e) {
- // Do nothing
- }
- }
- }
- });
- t.start();
- }
- public static void z32() {
- System.out.println("метод z32 в классе C");
- System.out.println(z13);
- }
- public static void z18() {
- System.out.println("метод z18 в классе C");
- System.out.println((z13 - 2));
- }
- public static void z10() {
- System.out.println("метод z10 в классе C");
- System.out.println(z34);
- }
- public static void z31() {
- System.out.println("метод z31 в классе C");
- System.out.println((z34 - 1));
- }
- public void z24(C r) {
- r.z42();
- }
- public void z24(E r) {
- r.z36();
- }
- }
- class E extends C {
- public E() {
- z21 = 3;
- z5 = 9;
- z4 = 7;
- z14 = 1L;
- z22 = 2L;
- }
- public void z42() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- init();
- int i = 0;
- while(true) {
- i++;
- try {
- synchronized(fileWrtr) {
- fileWrtr.writeObject("метод z42 в классе E (#" + String.valueOf(i) + ")");
- Thread.sleep(5);
- fileWrtr.reset();
- }
- } catch(Exception e) {
- // Do nothing
- }
- }
- }
- });
- t.start();
- }
- public void z27() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- init();
- int i = 0;
- while(true) {
- i++;
- try {
- synchronized(printOutput) {
- printOutput.writeObject("метод z27 в классе E (#" + String.valueOf(i) + ")");
- Thread.sleep(8);
- printOutput.reset();
- }
- } catch(Exception e) {
- // Do nothing
- }
- }
- }
- });
- t.start();
- }
- public void z3() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- init();
- int i = 0;
- while(true) {
- i++;
- try {
- synchronized(printOutput) {
- printOutput.writeObject("метод z3 в классе E (#" + String.valueOf(i) + ")");
- Thread.sleep(12);
- printOutput.flush();
- printOutput.reset();
- }
- } catch(Exception e) {
- // Do nothing
- }
- }
- }
- });
- t.start();
- }
- public void z9() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- init();
- int i = 0;
- while(true) {
- i++;
- try {
- synchronized(printOutput) {
- printOutput.writeObject("метод z9 в классе E (#" + String.valueOf(i) + ")");
- Thread.sleep(5);
- printOutput.flush();
- printOutput.reset();
- }
- } catch(Exception e) {
- // Do nothing
- }
- }
- }
- });
- t.start();
- }
- public void z15() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(true) {
- try {
- synchronized(cache) {
- getValueFromCache("https://www.google.com");
- Thread.sleep(14);
- }
- } catch(Exception e) {
- // Do nothing
- }
- }
- }
- });
- t.start();
- }
- public void z38() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(true) {
- try {
- synchronized(cache) {
- getValueFromCache("https://www.google.com");
- Thread.sleep(7);
- }
- } catch(Exception e) {
- // Do nothing
- }
- }
- }
- });
- t.start();
- }
- public void z23() {
- Thread t = new Thread(new Runnable() {
- public void run() {
- while(true) {
- try {
- synchronized(cache) {
- getValueFromCache("https://www.google.com");
- Thread.sleep(10);
- }
- } catch(Exception e) {
- // Do nothing
- }
- }
- }
- });
- t.start();
- }
- public static void z32() {
- System.out.println("метод z32 в классе E");
- System.out.println(z13--);
- }
- public static void z18() {
- System.out.println("метод z18 в классе E");
- System.out.println(z34);
- }
- public static void z10() {
- System.out.println("метод z10 в классе E");
- System.out.println((z34 - 5));
- }
- public static void z31() {
- System.out.println("метод z31 в классе E");
- System.out.println(z34);
- }
- public void z25() {
- for(int i = 0; i < 6; i++) {
- this.z43.add(String.valueOf(System.nanoTime()));
- // System.out.println(this.z43.size());
- }
- }
- public void z8() {
- for(int i = 0; i < 6; i++) {
- this.z6.add(String.valueOf(System.nanoTime()));
- // System.out.println(this.z6.size());
- }
- }
- public void z47() {
- for(int i = 0; i < 9; i++) {
- this.z20.add(String.valueOf(System.nanoTime()));
- // System.out.println(this.z20.size());
- }
- }
- public void z19() {
- for(int i = 0; i < 9; i++) {
- this.z6.add(String.valueOf(System.nanoTime()));
- // System.out.println(this.z6.size());
- }
- }
- public void z24(C r) {
- r.z27();
- }
- public void z24(E r) {
- r.z3();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement