-2
基本的には、このコードをnetbeans上で動作させます。それは私のためのものではありません。アドバイス、ダウンロードされたアトムはコンパイラでjavaにコードしたいのですが、マルチスレッドでの不正な式の開始
public class multithreading {
public static void execute(final String name)
{
for(int index=1; index<=5; index++)
{
System.out.println("thread " + name + " - " + index);
}
}
public static void main(String []args){
final Thread one = new Thread(() -> execute("first Thread"));
final Thread two = new Thread(() -> execute("second Thread"));
final Thread three = new Thread(() -> execute("third Thread"));
one.start();
two.start();
three.start();
}
}
エラー:
multithreading.java:18: error: illegal start of expression
final Thread one = new Thread(() -> execute("first Thread"));
^
multithreading.java:18: error: illegal start of expression
final Thread one = new Thread(() -> execute("first Thread"));
^
multithreading.java:19: error: illegal start of expression
final Thread two = new Thread(() -> execute("second Thread"));
^
multithreading.java:19: error: illegal start of expression
final Thread two = new Thread(() -> execute("second Thread"));
^
multithreading.java:20: error: illegal start of expression
final Thread three = new Thread(() -> execute("third Thread"));
^
multithreading.java:20: error: illegal start of expression
final Thread three = new Thread(() -> execute("third Thread"));
^
6 errors [Finished in 0.226s]
アトムが実行するJavaのバージョンは何ですか? – Ash
java -versionを実行しますか? ...あなたはJava 8を使用していますか –