Created
April 6, 2014 15:15
-
-
Save kurogelee/10007335 to your computer and use it in GitHub Desktop.
Javaでメソッド内部に名前付クラスを定義する(ネタ) ref: http://qiita.com/kurogelee/items/14743ce166223ab80403
This file contains hidden or 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
runB2:class neta.MethodInner$2ThreadB | |
runB1:class neta.MethodInner$1ThreadB | |
runC:class neta.MethodInner$ThreadC |
This file contains hidden or 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
package neta; | |
public class MethodInner { | |
public static void main(String[] args) { | |
new MethodInner().proc(); | |
class ThreadB extends Thread{ | |
public void run(){ | |
System.out.println("runB1:"+ getClass()); | |
} | |
} | |
new ThreadB().start(); | |
new ThreadC().start(); | |
} | |
private void proc() { | |
class ThreadB extends Thread{ | |
public void run(){ | |
System.out.println("runB2:"+ getClass()); | |
} | |
} | |
new ThreadB().start(); | |
} | |
static class ThreadC extends Thread{ | |
public void run(){ | |
System.out.println("runC:"+ getClass()); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment