Last active
September 25, 2018 11:53
-
-
Save sezemiadmin/44b54546abcab674612ef283159bd269 to your computer and use it in GitHub Desktop.
マルチスレッドプログラミング習得講座のサンプルコード
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
| public class Examples { | |
| public static void main(String[] args) { // staticで指定する | |
| Thread thread = Thread.currentThread(); // currentThread というメソッドを使う | |
| System.out.println(thread.getName()); // => main | |
| } | |
| } |
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
| public class MyExecutor implements Executor { | |
| public void execute(Runnable command) { | |
| // ここでさまざまな処理を実装可能 | |
| } | |
| } |
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
| class MyRunnable implements Runnable { | |
| public void run() { | |
| System.out.println("Running"); | |
| } | |
| } |
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
| 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