fork(1) download
  1. class main
  2. {
  3. /*
  4.   描画する絵を選択する処理
  5.   int i = checkInputKey(); //入力されたキー番号を取得
  6.  
  7.   */
  8.  ThreadClass tc = new ThreadClass("tc"); //カレントスレッド名を渡す
  9. tc.setDrawPattern(i); //描画するパターンiを渡す
  10.  tc.start(); //Thread起動
  11. }
  12.  
  13. //スレッド
  14. public class ThreadClass extends HandlerThread
  15. {
  16. ThreadClass(String s)
  17. {
  18. super(s);
  19. }
  20.  @Override
  21.  public void run()
  22.  {
  23. println("test1");
  24. println(Thread.currentThread().getName()); //tcが表示される。
  25. super.run(); // ←こいつがいるとここで止まる(フリーズはExceptionではキャッチされない)
  26. //Looper.prepare(); // ←superがいない時に有効化
  27. println("test2");
  28. Handler hi = new Handler(this.getLooper());
  29. /* this.getLooperでは、呼び出した際に止まってしまう
  30.    Looper.getMainLooper() だと正常に描画されるが、描画中main部分が動作不能となる
  31.   Looper.myLooper() だと、動作はするがhi.postのrun()が起動せず終わってしまう
  32.   (myLooper()の時は、Looper.prepare()を有効化させないとNullPointer)
  33.   何も書かなければmyLooper同様な動作をする
  34.   */
  35. println("test3");
  36.  
  37.   hi.post(new Runnable() {
  38.    public void run () {
  39. println("test4");
  40.     //描画処理
  41.    }
  42.   });
  43.  }
  44.  
  45. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:8: illegal character: \12288
?ThreadClass tc = new ThreadClass("tc");      //????????????
^
Main.java:8: ';' expected
?ThreadClass tc = new ThreadClass("tc");      //????????????
 ^
Main.java:8: <identifier> expected
?ThreadClass tc = new ThreadClass("tc");      //????????????
               ^
Main.java:9: <identifier> expected
  tc.setDrawPattern(i); //????????i???
                   ^
Main.java:9: <identifier> expected
  tc.setDrawPattern(i); //????????i???
                     ^
Main.java:10: illegal character: \12288
?tc.start();          //Thread??
^
Main.java:10: ';' expected
?tc.start();          //Thread??
 ^
Main.java:10: illegal start of type
?tc.start();          //Thread??
   ^
Main.java:20: illegal character: \12288
?@Override
^
Main.java:20: ';' expected
?@Override
 ^
Main.java:21: illegal character: \12288
?public void run()
^
Main.java:22: illegal character: \12288
?{
^
Main.java:37: illegal character: \12288
??hi.post(new Runnable() {
^
Main.java:37: illegal character: \12288
??hi.post(new Runnable() {
 ^
Main.java:37: ';' expected
??hi.post(new Runnable() {
    ^
Main.java:38: illegal character: \12288
???public void run () {
^
Main.java:38: illegal character: \12288
???public void run () {
 ^
Main.java:38: illegal character: \12288
???public void run () {
  ^
Main.java:38: <identifier> expected
???public void run () {
   ^
Main.java:38: ';' expected
???public void run () {
         ^
Main.java:38: invalid method declaration; return type required
???public void run () {
               ^
Main.java:40: illegal character: \12288
????//????
^
Main.java:40: illegal character: \12288
????//????
 ^
Main.java:40: illegal character: \12288
????//????
  ^
Main.java:40: illegal character: \12288
????//????
   ^
Main.java:41: illegal character: \12288
???}
^
Main.java:41: illegal character: \12288
???}
 ^
Main.java:41: illegal character: \12288
???}
  ^
Main.java:42: illegal character: \12288
??});
^
Main.java:42: illegal character: \12288
??});
 ^
Main.java:43: illegal character: \12288
?}
^
31 errors
stdout
Standard output is empty