WordTreadのコーディングをしています。
参考書は翔泳社の「javaの絵本」です。
スレッド処理のコーディング中なのですが、
下部の
tick.start();
と
tack.start();
がシンボルを見つけられませんと出てきてビルドできません。
上記のここ記載通りにrunメソッドもある状態なので、
問題なくいくように思えたのですが。。。
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package hoge.nyumon.javaclass; /** * * @author USER */ class WordThread{ private final String word; private final int time; private final int count; public WordThread(String w, int t,int c){ word = w; time = t; count = c; } public void run(){ for(int i = 0; i < count; i++){ System.out.print(word); try { Thread.sleep(time); } catch (Exception e) { } } } public static void main(String[] args){ WordThread tick = new WordThread("tick",1000,4); WordThread tack = new WordThread(" tack\n",1000,3); tick.start(); try { Thread.sleep(500); }catch (Exception e) { } tack.start(); } }
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。