permainan Game domino sample.



You can replace this text by going to "Layout" and then "Page Elements" section. Edit " About "
Copyright © 2008 ARPEGGIOS. All Rights Reserved.
Design by Padd IT Solutions - Blogger Notes Template by Blogger Templates
|
1
2
3
|
public interface Runnable { void run();} |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
class RunnableThread implements Runnable { Thread runner; public RunnableThread() { } public RunnableThread(String threadName) { runner = new Thread(this, threadName); // (1) Buat thread baru. System.out.println(runner.getName()); runner.start(); // (2) Memulai eksekusi thread tersebut. } public void run() { //Tampilkan info tentang thread ini System.out.println(Thread.currentThread()); }}public class RunnableExample { public static void main(String[] args) { Thread thread1 = new Thread(new RunnableThread(), "thread1"); Thread thread2 = new Thread(new RunnableThread(), "thread2"); RunnableThread thread3 = new RunnableThread("thread3"); //Memulai eksekusi thread. thread1.start(); thread2.start(); try { //delay selama satu detik (1000 ms). Thread.currentThread().sleep(1000); } catch (InterruptedException e) { } //Tampilkan info tentang thread main (utama). System.out.println(Thread.currentThread()); }} |
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
class XThread extends Thread { XThread() { } XThread(String threadName) { super(threadName); // Memulai thread. System.out.println(this); start(); } public void run() { //Tampilkan info tentang thread ini System.out.println(Thread.currentThread().getName()); }}public class ThreadExample { public static void main(String[] args) { Thread thread1 = new Thread(new XThread(), "thread1"); Thread thread2 = new Thread(new XThread(), "thread2"); // 2 thread diberikan nama default Thread thread3 = new XThread(); Thread thread4 = new XThread(); Thread thread5 = new XThread("thread5"); //Memulai eksekusi thread thread1.start(); thread2.start(); thread3.start(); thread4.start(); try { //Metode sleep() dipanggil pada thred main (utama), delay 1 detik. Thread.currentThread().sleep(1000); } catch (InterruptedException e) { } //Tampilkan info tentang thread main System.out.println(Thread.currentThread()); }} |
|
1
2
3
4
5
6
|
( new Thread() { public void run() { for(;;) System.out.println(”Stop the world!”); }}).start(); |
Copyright © 2010 ARPEGGIOS
Blogger Templates by Splashy Templates