-4

I have a program called Main.java, shown as below. After compilation of this program, there will be two .class file: Main.class and Main$1.class. My problem is the two .class files are exactly the same.

Anyone knows what is wrong?

I wan to instrument some codes in the run() method of the new thread, but I cannot find the instructions of codes in the run() method of a new thread.

public class Main{
    public static void main(String...args){
         Thread t=new Thread(){
         @Override
             public void run(){
             System.out.println("xxxx");
             }
         };
    t.start();
    }
}
Xiong
  • 1
  • 1

1 Answers1

3

My money would be on you not comparing the two class files correctly. I'd bet that you're writing something like this in your bash-like prompt:

md5sum Main.class Main$1.class

(or some checksumming tool other than md5sum)

This is actually substituting the variable called 1 in the string - unless you've got that variable defined, that variable is empty, so that is expanding to:

md5sum Main.class Main.class

which will show as the same file contents.

Try single-quoting the second string:

md5sum Main.class 'Main$1.class'
Andy Turner
  • 137,514
  • 11
  • 162
  • 243