Skip to content

Instantly share code, notes, and snippets.

@kurogelee
Created April 6, 2014 15:15
Show Gist options
  • Save kurogelee/10007335 to your computer and use it in GitHub Desktop.
Save kurogelee/10007335 to your computer and use it in GitHub Desktop.
Javaでメソッド内部に名前付クラスを定義する(ネタ) ref: http://qiita.com/kurogelee/items/14743ce166223ab80403
runB2:class neta.MethodInner$2ThreadB
runB1:class neta.MethodInner$1ThreadB
runC:class neta.MethodInner$ThreadC
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