Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Tampilkan implements Runnable{
- @Override
- public void run() {
- for(int i = 0; i<5; i++){
- System.out.println("Ini angka "+i);
- try{
- Thread.sleep(100);//digunakan supaya cpu tidak terbebani
- }catch(InterruptedException e){
- e.printStackTrace();
- }
- }
- }
- }
- public class ContohThread {
- public static void main(String[] args){
- Thread tampil1 = new Thread(new Tampilkan());
- tampil1.start();
- Thread tampil2 = new Thread(new Tampilkan());
- tampil2.start();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment