Last active
July 2, 2020 13:18
-
-
Save kortov/169064151c569958057f45ae0207bbfe to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// class version 52.0 (52) | |
// access flags 0x20 | |
class Main$ReadThread extends java/lang/Thread { | |
// compiled from: Main.java | |
// access flags 0x8 | |
static INNERCLASS Main$ReadThread Main ReadThread | |
// access flags 0x0 | |
<init>()V | |
L0 | |
LINENUMBER 18 L0 | |
ALOAD 0 | |
INVOKESPECIAL java/lang/Thread.<init> ()V | |
RETURN | |
L1 | |
LOCALVARIABLE this LMain$ReadThread; L0 L1 0 | |
MAXSTACK = 1 | |
MAXLOCALS = 1 | |
// access flags 0x1 | |
public run()V | |
L0 | |
LINENUMBER 21 L0 | |
GETSTATIC Main.i : I | |
ISTORE 1 | |
L1 | |
LINENUMBER 22 L1 | |
FRAME APPEND [I] | |
ILOAD 1 | |
ICONST_5 | |
IF_ICMPGE L2 | |
L3 | |
LINENUMBER 24 L3 | |
ILOAD 1 | |
GETSTATIC Main.i : I | |
IF_ICMPEQ L1 | |
L4 | |
LINENUMBER 25 L4 | |
GETSTATIC java/lang/System.out : Ljava/io/PrintStream; | |
NEW java/lang/StringBuilder | |
DUP | |
INVOKESPECIAL java/lang/StringBuilder.<init> ()V | |
LDC "New value of i " | |
INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder; | |
ILOAD 1 | |
INVOKEVIRTUAL java/lang/StringBuilder.append (I)Ljava/lang/StringBuilder; | |
INVOKEVIRTUAL java/lang/StringBuilder.toString ()Ljava/lang/String; | |
INVOKEVIRTUAL java/io/PrintStream.println (Ljava/lang/String;)V | |
L5 | |
LINENUMBER 26 L5 | |
GETSTATIC Main.i : I | |
ISTORE 1 | |
GOTO L1 | |
L2 | |
LINENUMBER 29 L2 | |
FRAME SAME | |
RETURN | |
L6 | |
LOCALVARIABLE this LMain$ReadThread; L0 L6 0 | |
LOCALVARIABLE localI I L1 L6 1 | |
MAXSTACK = 3 | |
MAXLOCALS = 2 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// class version 52.0 (52) | |
// access flags 0x20 | |
class Main$ReadThread extends java/lang/Thread { | |
// compiled from: Main.java | |
// access flags 0x8 | |
static INNERCLASS Main$ReadThread Main ReadThread | |
// access flags 0x0 | |
<init>()V | |
L0 | |
LINENUMBER 18 L0 | |
ALOAD 0 | |
INVOKESPECIAL java/lang/Thread.<init> ()V | |
RETURN | |
L1 | |
LOCALVARIABLE this LMain$ReadThread; L0 L1 0 | |
MAXSTACK = 1 | |
MAXLOCALS = 1 | |
// access flags 0x1 | |
public run()V | |
L0 | |
LINENUMBER 21 L0 | |
GETSTATIC Main.i : I | |
ISTORE 1 | |
L1 | |
LINENUMBER 22 L1 | |
FRAME APPEND [I] | |
ILOAD 1 | |
ICONST_5 | |
IF_ICMPGE L2 | |
L3 | |
LINENUMBER 23 L3 | |
GETSTATIC java/lang/System.out : Ljava/io/PrintStream; | |
LDC "" | |
INVOKEVIRTUAL java/io/PrintStream.println (Ljava/lang/String;)V | |
L4 | |
LINENUMBER 24 L4 | |
ILOAD 1 | |
GETSTATIC Main.i : I | |
IF_ICMPEQ L1 | |
L5 | |
LINENUMBER 25 L5 | |
GETSTATIC java/lang/System.out : Ljava/io/PrintStream; | |
NEW java/lang/StringBuilder | |
DUP | |
INVOKESPECIAL java/lang/StringBuilder.<init> ()V | |
LDC "New value of i " | |
INVOKEVIRTUAL java/lang/StringBuilder.append (Ljava/lang/String;)Ljava/lang/StringBuilder; | |
ILOAD 1 | |
INVOKEVIRTUAL java/lang/StringBuilder.append (I)Ljava/lang/StringBuilder; | |
INVOKEVIRTUAL java/lang/StringBuilder.toString ()Ljava/lang/String; | |
INVOKEVIRTUAL java/io/PrintStream.println (Ljava/lang/String;)V | |
L6 | |
LINENUMBER 26 L6 | |
GETSTATIC Main.i : I | |
ISTORE 1 | |
GOTO L1 | |
L2 | |
LINENUMBER 29 L2 | |
FRAME SAME | |
RETURN | |
L7 | |
LOCALVARIABLE this LMain$ReadThread; L0 L7 0 | |
LOCALVARIABLE localI I L1 L7 1 | |
MAXSTACK = 3 | |
MAXLOCALS = 2 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Main { | |
static int i = 0; | |
static class WriteThread extends Thread { | |
@Override | |
public void run() { | |
while (i < 5) { | |
System.out.println("Increment i to " + (++i)); | |
try { | |
Thread.sleep(1000); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} | |
} | |
} | |
static class ReadThread extends Thread { | |
@Override | |
public void run() { | |
int localI = i; | |
while (localI < 5) { | |
// System.out.println(""); | |
if (localI != i) { | |
System.out.println("New value of i " + localI); | |
localI = i; | |
} | |
} | |
} | |
} | |
public static void main(String[] args) throws InterruptedException { | |
ReadThread readThread = new ReadThread(); | |
WriteThread writeThread = new WriteThread(); | |
writeThread.start(); | |
readThread.start(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment