Skip to content

Instantly share code, notes, and snippets.

@sezemiadmin
Last active September 25, 2018 11:53
Show Gist options
  • Select an option

  • Save sezemiadmin/44b54546abcab674612ef283159bd269 to your computer and use it in GitHub Desktop.

Select an option

Save sezemiadmin/44b54546abcab674612ef283159bd269 to your computer and use it in GitHub Desktop.
マルチスレッドプログラミング習得講座のサンプルコード
public class Examples {
public static void main(String[] args) { // staticで指定する
Thread thread = Thread.currentThread(); // currentThread というメソッドを使う
System.out.println(thread.getName()); // => main
}
}
public class MyExecutor implements Executor {
public void execute(Runnable command) {
// ここでさまざまな処理を実装可能
}
}
class MyRunnable implements Runnable {
public void run() {
System.out.println("Running");
}
}
public class ThreadExamples {
public static void main(String[] args) { // staticで指定する
Thread t = new Thread(new MyRunnable());
t.start();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment