回答編集履歴

1

コードの間違いを修正

2019/01/08 09:58

投稿

KSwordOfHaste
KSwordOfHaste

スコア18394

test CHANGED
@@ -76,47 +76,53 @@
76
76
 
77
77
  if (rb1.isSelected()) {
78
78
 
79
- Thread thread = new Thread(() -> {
79
+ Thread thread = new Thread() {
80
80
 
81
- Platform.runLater(() -> textArea.appendText("first\n"));
81
+ @Override
82
82
 
83
- // for文をforEachに変更しています。Platform.runLaterで用いるlambda式から
83
+ public void run() {
84
84
 
85
- // ループの制御変数iを参照するにはiがfinalでなくてはならず、forループが使いにくいからです
85
+ Platform.runLater(() -> textArea.appendText("first\n"));
86
86
 
87
- IntStream.range(0, 4).forEach(i -> {
87
+ // for文をforEachに変更しています。Platform.runLaterで用いるlambda式から
88
88
 
89
- try {
89
+ // ループの制御変数iを参照するにはiがfinalでなくてはならず、forループが使いにくいからです
90
90
 
91
- sleep(1000);
91
+ IntStream.range(0, 4).forEach(i -> {
92
92
 
93
- } catch (InterruptedException e) {
93
+ try {
94
94
 
95
- e.printStackTrace(); // デバッグ用
95
+ sleep(1000);
96
96
 
97
- }
97
+ } catch (InterruptedException e) {
98
98
 
99
- Platform.runLater(() -> textArea.appendText("line" + i + "\n"));
99
+ e.printStackTrace(); // デバッグ用
100
100
 
101
- });
101
+ }
102
102
 
103
- Platform.runLater(() -> textArea.appendText("last\n"));
103
+ Platform.runLater(() -> textArea.appendText("line" + i + "\n"));
104
104
 
105
- Platform.runLater(() -> {
105
+ });
106
106
 
107
- try {
107
+ Platform.runLater(() -> textArea.appendText("last\n"));
108
108
 
109
- join();
109
+ Platform.runLater(() -> {
110
110
 
111
- } catch (InterruptedException e) {
111
+ try {
112
112
 
113
- e.printStackTrace(); // デバッグ用
113
+ join();
114
114
 
115
- }
115
+ } catch (InterruptedException e) {
116
116
 
117
- });
117
+ e.printStackTrace(); // デバッグ用
118
118
 
119
+ }
120
+
119
- });
121
+ });
122
+
123
+ }
124
+
125
+ };
120
126
 
121
127
  thread.start();
122
128