You are on page 1of 46

TUGAS 1 - MULTITHREADING EXPERIMENT

Disusun Oleh :
1. 4520210022 – Kevin Feriansyah Wibowo
2. 4520210012 – Yusri Risky Amelia
3. 4520210014 – Muhammad Aldiansyah
4. 4520210018 – Bagas Dwi Yunanto
5. 4520210038 – Tegar Fikri Alamsyah
 Loop 1 dengan 5 thread dan 10x, 100x, 1000x, 10000x, 1000000x Iteration
Sourcecode :
10x

public class Loop1 extends Thread{


private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=10; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
}
}

100x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=100; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
}
}

1000x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=1000; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
}
}

10000x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=10000; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
}
}

1000000x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=1000000; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
}
}

Loop 1 dengan 10 thread dan 10x, 100x, 1000x, 10000x, 1000000x Iteration
Sourcecode :
10x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=10; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");
Loop1 t6 = new Loop1 ("Dito");
Loop1 t7 = new Loop1 ("Angga");
Loop1 t8 = new Loop1 ("jave");
Loop1 t9 = new Loop1 ("joan");
Loop1 t10 = new Loop1 ("rana");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
}
}

100x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=100; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");
Loop1 t6 = new Loop1 ("Dito");
Loop1 t7 = new Loop1 ("Angga");
Loop1 t8 = new Loop1 ("jave");
Loop1 t9 = new Loop1 ("joan");
Loop1 t10 = new Loop1 ("rana");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
}
}

1000x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=1000; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");
Loop1 t6 = new Loop1 ("Dito");
Loop1 t7 = new Loop1 ("Angga");
Loop1 t8 = new Loop1 ("jave");
Loop1 t9 = new Loop1 ("joan");
Loop1 t10 = new Loop1 ("rana");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
}
}

10000x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=10000; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}
long endTime = System.currentTimeMillis();
System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");
Loop1 t6 = new Loop1 ("Dito");
Loop1 t7 = new Loop1 ("Angga");
Loop1 t8 = new Loop1 ("jave");
Loop1 t9 = new Loop1 ("joan");
Loop1 t10 = new Loop1 ("rana");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
}
}

1000000x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=1000000; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");
Loop1 t6 = new Loop1 ("Dito");
Loop1 t7 = new Loop1 ("Angga");
Loop1 t8 = new Loop1 ("jave");
Loop1 t9 = new Loop1 ("joan");
Loop1 t10 = new Loop1 ("rana");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
}
}

Loop 1 dengan 15 thread dan 10x, 100x, 1000x, 10000x, 1000000x Iteration
Sourcecode :
10x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=10; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");
Loop1 t6 = new Loop1 ("Dito");
Loop1 t7 = new Loop1 ("Angga");
Loop1 t8 = new Loop1 ("jave");
Loop1 t9 = new Loop1 ("joan");
Loop1 t10 = new Loop1 ("rana");
Loop1 t11 = new Loop1 ("irfan");
Loop1 t12 = new Loop1 ("valdi");
Loop1 t13 = new Loop1 ("Roiwe");
Loop1 t14 = new Loop1 ("Linse");
Loop1 t15 = new Loop1 ("ferry");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
}
}

100x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=100; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");
Loop1 t6 = new Loop1 ("Dito");
Loop1 t7 = new Loop1 ("Angga");
Loop1 t8 = new Loop1 ("jave");
Loop1 t9 = new Loop1 ("joan");
Loop1 t10 = new Loop1 ("rana");
Loop1 t11 = new Loop1 ("irfan");
Loop1 t12 = new Loop1 ("valdi");
Loop1 t13 = new Loop1 ("Roiwe");
Loop1 t14 = new Loop1 ("Linse");
Loop1 t15 = new Loop1 ("ferry");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
}
}

1000x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=1000; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");
Loop1 t6 = new Loop1 ("Dito");
Loop1 t7 = new Loop1 ("Angga");
Loop1 t8 = new Loop1 ("jave");
Loop1 t9 = new Loop1 ("joan");
Loop1 t10 = new Loop1 ("rana");
Loop1 t11 = new Loop1 ("irfan");
Loop1 t12 = new Loop1 ("valdi");
Loop1 t13 = new Loop1 ("Roiwe");
Loop1 t14 = new Loop1 ("Linse");
Loop1 t15 = new Loop1 ("ferry");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
}
}

10000x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=10000; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");
Loop1 t6 = new Loop1 ("Dito");
Loop1 t7 = new Loop1 ("Angga");
Loop1 t8 = new Loop1 ("jave");
Loop1 t9 = new Loop1 ("joan");
Loop1 t10 = new Loop1 ("rana");
Loop1 t11 = new Loop1 ("irfan");
Loop1 t12 = new Loop1 ("valdi");
Loop1 t13 = new Loop1 ("Roiwe");
Loop1 t14 = new Loop1 ("Linse");
Loop1 t15 = new Loop1 ("ferry");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
}
}

1000000x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=1000000; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");
Loop1 t6 = new Loop1 ("Dito");
Loop1 t7 = new Loop1 ("Angga");
Loop1 t8 = new Loop1 ("jave");
Loop1 t9 = new Loop1 ("joan");
Loop1 t10 = new Loop1 ("rana");
Loop1 t11 = new Loop1 ("irfan");
Loop1 t12 = new Loop1 ("valdi");
Loop1 t13 = new Loop1 ("Roiwe");
Loop1 t14 = new Loop1 ("Linse");
Loop1 t15 = new Loop1 ("ferry");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
}
}

Loop 1 dengan 20 thread dan 10x, 100x, 1000x, 10000x, 1000000x Iteration
Sourcecode :
10x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=10; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");
Loop1 t6 = new Loop1 ("Dito");
Loop1 t7 = new Loop1 ("Angga");
Loop1 t8 = new Loop1 ("jave");
Loop1 t9 = new Loop1 ("joan");
Loop1 t10 = new Loop1 ("rana");
Loop1 t11 = new Loop1 ("irfan");
Loop1 t12 = new Loop1 ("valdi");
Loop1 t13 = new Loop1 ("Roiwe");
Loop1 t14 = new Loop1 ("Linse");
Loop1 t15 = new Loop1 ("ferry");
Loop1 t16 = new Loop1 ("sipes");
Loop1 t17 = new Loop1 ("bianca");
Loop1 t18 = new Loop1 ("Amber");
Loop1 t19 = new Loop1 ("Oide");
Loop1 t20 = new Loop1 ("valery");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
t16.start();
t17.start();
t18.start();
t19.start();
t20.start();
}
}

100x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=100; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");
Loop1 t6 = new Loop1 ("Dito");
Loop1 t7 = new Loop1 ("Angga");
Loop1 t8 = new Loop1 ("jave");
Loop1 t9 = new Loop1 ("joan");
Loop1 t10 = new Loop1 ("rana");
Loop1 t11 = new Loop1 ("irfan");
Loop1 t12 = new Loop1 ("valdi");
Loop1 t13 = new Loop1 ("Roiwe");
Loop1 t14 = new Loop1 ("Linse");
Loop1 t15 = new Loop1 ("ferry");
Loop1 t16 = new Loop1 ("sipes");
Loop1 t17 = new Loop1 ("bianca");
Loop1 t18 = new Loop1 ("Amber");
Loop1 t19 = new Loop1 ("Oide");
Loop1 t20 = new Loop1 ("valery");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
t16.start();
t17.start();
t18.start();
t19.start();
t20.start();
}
}

1000x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=1000; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");
Loop1 t6 = new Loop1 ("Dito");
Loop1 t7 = new Loop1 ("Angga");
Loop1 t8 = new Loop1 ("jave");
Loop1 t9 = new Loop1 ("joan");
Loop1 t10 = new Loop1 ("rana");
Loop1 t11 = new Loop1 ("irfan");
Loop1 t12 = new Loop1 ("valdi");
Loop1 t13 = new Loop1 ("Roiwe");
Loop1 t14 = new Loop1 ("Linse");
Loop1 t15 = new Loop1 ("ferry");
Loop1 t16 = new Loop1 ("sipes");
Loop1 t17 = new Loop1 ("bianca");
Loop1 t18 = new Loop1 ("Amber");
Loop1 t19 = new Loop1 ("Oide");
Loop1 t20 = new Loop1 ("valery");
t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
t16.start();
t17.start();
t18.start();
t19.start();
t20.start();
}
}

10000x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=10000; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");
Loop1 t6 = new Loop1 ("Dito");
Loop1 t7 = new Loop1 ("Angga");
Loop1 t8 = new Loop1 ("jave");
Loop1 t9 = new Loop1 ("joan");
Loop1 t10 = new Loop1 ("rana");
Loop1 t11 = new Loop1 ("irfan");
Loop1 t12 = new Loop1 ("valdi");
Loop1 t13 = new Loop1 ("Roiwe");
Loop1 t14 = new Loop1 ("Linse");
Loop1 t15 = new Loop1 ("ferry");
Loop1 t16 = new Loop1 ("sipes");
Loop1 t17 = new Loop1 ("bianca");
Loop1 t18 = new Loop1 ("Amber");
Loop1 t19 = new Loop1 ("Oide");
Loop1 t20 = new Loop1 ("valery");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
t16.start();
t17.start();
t18.start();
t19.start();
t20.start();
}
}

1000000x
public class Loop1 extends Thread{
private String myName; //inisialisasi
public Loop1 (String name){ //constuctor
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis(); //catat waktu awal
for(int i = 1; i<=1000000; i++){ //Process Looping
System.out.println(myName + " (" + i + ")");
}

long endTime = System.currentTimeMillis();


System.out.println("Waktu " + myName + ": " + (endTime-startTime)
+ " Milisecond"); //catat waktu akhir
}
public static void main (String[] args){
Loop1 t1 = new Loop1 ("Budi");
Loop1 t2 = new Loop1 ("Ferianto");
Loop1 t3 = new Loop1 ("Randi");
Loop1 t4 = new Loop1 ("Febri");
Loop1 t5 = new Loop1 ("Pamungkas");
Loop1 t6 = new Loop1 ("Dito");
Loop1 t7 = new Loop1 ("Angga");
Loop1 t8 = new Loop1 ("jave");
Loop1 t9 = new Loop1 ("joan");
Loop1 t10 = new Loop1 ("rana");
Loop1 t11 = new Loop1 ("irfan");
Loop1 t12 = new Loop1 ("valdi");
Loop1 t13 = new Loop1 ("Roiwe");
Loop1 t14 = new Loop1 ("Linse");
Loop1 t15 = new Loop1 ("ferry");
Loop1 t16 = new Loop1 ("sipes");
Loop1 t17 = new Loop1 ("bianca");
Loop1 t18 = new Loop1 ("Amber");
Loop1 t19 = new Loop1 ("Oide");
Loop1 t20 = new Loop1 ("valery");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
t16.start();
t17.start();
t18.start();
t19.start();
t20.start();
}
}
Grafik
Loop 1

Interation
Thread
10x 100x 1000x 10000x 1000000x
5 Thread 126 760 5949 28340 141.639
10 Thread 379 1256 9988 8693 288441
15 Thread 277 3663 12592 13937 414220
20 Thread 296 2216 10918 9558 539079

Penjelasan Hasil :
Percobaan dimulai dari Loop 1 dengan 5 thread dan 10x, 100x, 1000x, 10000x, 1000000x Iteration.
Di 10x loop didapatkan waktu rata-rata 126ms.
Di 100x loop didapatkan waktu rata-rata 760ms.
Di 1000x loop didapatkan waktu rata-rata 5949ms.
Di 10000x loop didapatkan waktu rata-rata 28340ms.
Di 1000000x loop didapatkan waktu rata-rata 141.639ms.

Percobaan kedua dari Loop 1 dengan 10 thread dan 10x, 100x, 1000x, 10000x, 1000000x Iteration
Di 10x loop didapatkan waktu rata-rata 379ms.
Di 100x loop didapatkan waktu rata-rata 1256ms.
Di 1000x loop didapatkan waktu rata-rata 9988ms.
Di 10000x loop didapatkan waktu rata-rata 8693ms.
Di 1000000x loop didapatkan waktu rata-rata 288441ms.

Percobaan kedua dari Loop 1 dengan 15 thread dan 10x, 100x, 1000x, 10000x, 1000000x Iteration
Di 10x loop didapatkan waktu rata-rata 277ms.
Di 100x loop didapatkan waktu rata-rata 3663ms.
Di 1000x loop didapatkan waktu rata-rata 12592ms.
Di 10000x loop didapatkan waktu rata-rata 13937ms.
Di 1000000x loop didapatkan waktu rata-rata 414220ms

Percobaan kedua dari Loop 1 dengan 20 thread dan 10x, 100x, 1000x, 10000x, 1000000x Iteration
Di 10x loop didapatkan waktu rata-rata 296ms.
Di 100x loop didapatkan waktu rata-rata 2216ms.
Di 1000x loop didapatkan waktu rata-rata 10918ms.
Di 10000x loop didapatkan waktu rata-rata 9558ms.
Di 1000000x loop didapatkan waktu rata-rata 539079ms
 Loop 3 dengan 5 thread dan 10x, 100x, 1000x, 10000x, 1000000x Iteration
Sourcecode :

10x
public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=10; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
}
}

100x

public class Loop3 extends Thread {


private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=10; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
}
}

1000x
public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=10; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
}
}

10000x
public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=10000; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}
public static void main(String[] args){
Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
}
}

1000000x
public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=1000000; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
}
}

 Loop 3 dengan 10 thread dan 10x, 100x, 1000x, 10000x, 1000000x Iteration
Sourcecode :
10x

public class Loop3 extends Thread {


private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=10; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");
Loop3 t6 = new Loop3("Thread 6, Iteration ");
Loop3 t7 = new Loop3("Thread 7, Iteration ");
Loop3 t8 = new Loop3("Thread 8, Iteration ");
Loop3 t9 = new Loop3("Thread 9, Iteration ");
Loop3 t10 = new Loop3("Thread 10, Iteration ");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
}
}

100x
public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=100; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");
Loop3 t6 = new Loop3("Thread 6, Iteration ");
Loop3 t7 = new Loop3("Thread 7, Iteration ");
Loop3 t8 = new Loop3("Thread 8, Iteration ");
Loop3 t9 = new Loop3("Thread 9, Iteration ");
Loop3 t10 = new Loop3("Thread 10, Iteration ");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
}
}

1000x
public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=1000; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");
Loop3 t6 = new Loop3("Thread 6, Iteration ");
Loop3 t7 = new Loop3("Thread 7, Iteration ");
Loop3 t8 = new Loop3("Thread 8, Iteration ");
Loop3 t9 = new Loop3("Thread 9, Iteration ");
Loop3 t10 = new Loop3("Thread 10, Iteration ");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
}
}

10000x
public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=10000; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");
Loop3 t6 = new Loop3("Thread 6, Iteration ");
Loop3 t7 = new Loop3("Thread 7, Iteration ");
Loop3 t8 = new Loop3("Thread 8, Iteration ");
Loop3 t9 = new Loop3("Thread 9, Iteration ");
Loop3 t10 = new Loop3("Thread 10, Iteration ");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
}
}

1000000x
public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=1000000; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");
Loop3 t6 = new Loop3("Thread 6, Iteration ");
Loop3 t7 = new Loop3("Thread 7, Iteration ");
Loop3 t8 = new Loop3("Thread 8, Iteration ");
Loop3 t9 = new Loop3("Thread 9, Iteration ");
Loop3 t10 = new Loop3("Thread 10, Iteration ");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
}
}

Loop 3 dengan 15 thread dan 10x, 100x, 1000x, 10000x, 1000000x Iteration
Sourcecode :
10x
public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=10; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");
Loop3 t6 = new Loop3("Thread 6, Iteration ");
Loop3 t7 = new Loop3("Thread 7, Iteration ");
Loop3 t8 = new Loop3("Thread 8, Iteration ");
Loop3 t9 = new Loop3("Thread 9, Iteration ");
Loop3 t10 = new Loop3("Thread 10, Iteration ");
Loop3 t11 = new Loop3("Thread 11, Iteration ");
Loop3 t12 = new Loop3("Thread 12, Iteration ");
Loop3 t13 = new Loop3("Thread 13, Iteration ");
Loop3 t14 = new Loop3("Thread 14, Iteration ");
Loop3 t15 = new Loop3("Thread 15, Iteration ");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
}
}

100x
Public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=100; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");
Loop3 t6 = new Loop3("Thread 6, Iteration ");
Loop3 t7 = new Loop3("Thread 7, Iteration ");
Loop3 t8 = new Loop3("Thread 8, Iteration ");
Loop3 t9 = new Loop3("Thread 9, Iteration ");
Loop3 t10 = new Loop3("Thread 10, Iteration ");
Loop3 t11 = new Loop3("Thread 11, Iteration ");
Loop3 t12 = new Loop3("Thread 12, Iteration ");
Loop3 t13 = new Loop3("Thread 13, Iteration ");
Loop3 t14 = new Loop3("Thread 14, Iteration ");
Loop3 t15 = new Loop3("Thread 15, Iteration ");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
}
}

1000x
Public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=1000; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");
Loop3 t6 = new Loop3("Thread 6, Iteration ");
Loop3 t7 = new Loop3("Thread 7, Iteration ");
Loop3 t8 = new Loop3("Thread 8, Iteration ");
Loop3 t9 = new Loop3("Thread 9, Iteration ");
Loop3 t10 = new Loop3("Thread 10, Iteration ");
Loop3 t11 = new Loop3("Thread 11, Iteration ");
Loop3 t12 = new Loop3("Thread 12, Iteration ");
Loop3 t13 = new Loop3("Thread 13, Iteration ");
Loop3 t14 = new Loop3("Thread 14, Iteration ");
Loop3 t15 = new Loop3("Thread 15, Iteration ");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
}
}

10000x
Public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}
public void run(){
long startTime = System.currentTimeMillis();
for (int i=1; i<=10000; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");
Loop3 t6 = new Loop3("Thread 6, Iteration ");
Loop3 t7 = new Loop3("Thread 7, Iteration ");
Loop3 t8 = new Loop3("Thread 8, Iteration ");
Loop3 t9 = new Loop3("Thread 9, Iteration ");
Loop3 t10 = new Loop3("Thread 10, Iteration ");
Loop3 t11 = new Loop3("Thread 11, Iteration ");
Loop3 t12 = new Loop3("Thread 12, Iteration ");
Loop3 t13 = new Loop3("Thread 13, Iteration ");
Loop3 t14 = new Loop3("Thread 14, Iteration ");
Loop3 t15 = new Loop3("Thread 15, Iteration ");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
}
}

1000000x
public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=1000000; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");
Loop3 t6 = new Loop3("Thread 6, Iteration ");
Loop3 t7 = new Loop3("Thread 7, Iteration ");
Loop3 t8 = new Loop3("Thread 8, Iteration ");
Loop3 t9 = new Loop3("Thread 9, Iteration ");
Loop3 t10 = new Loop3("Thread 10, Iteration ");
Loop3 t11 = new Loop3("Thread 11, Iteration ");
Loop3 t12 = new Loop3("Thread 12, Iteration ");
Loop3 t13 = new Loop3("Thread 13, Iteration ");
Loop3 t14 = new Loop3("Thread 14, Iteration ");
Loop3 t15 = new Loop3("Thread 15, Iteration ");

t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
}
}

Loop 3 dengan 20 thread dan 10x, 100x, 1000x, 10000x, 1000000x Iteration
Sourcecode :
10x
public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=10000; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");
Loop3 t6 = new Loop3("Thread 6, Iteration ");
Loop3 t7 = new Loop3("Thread 7, Iteration ");
Loop3 t8 = new Loop3("Thread 8, Iteration ");
Loop3 t9 = new Loop3("Thread 9, Iteration ");
Loop3 t10 = new Loop3("Thread 10, Iteration ");
Loop3 t11 = new Loop3("Thread 11, Iteration ");
Loop3 t12 = new Loop3("Thread 12, Iteration ");
Loop3 t13 = new Loop3("Thread 13, Iteration ");
Loop3 t14 = new Loop3("Thread 14, Iteration ");
Loop3 t15 = new Loop3("Thread 15, Iteration ");
Loop3 t16 = new Loop3("Thread 16, Iteration ");
Loop3 t17 = new Loop3("Thread 17, Iteration ");
Loop3 t18 = new Loop3("Thread 18, Iteration ");
Loop3 t19 = new Loop3("Thread 19, Iteration ");
Loop3 t20 = new Loop3("Thread 20, Iteration ");
t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
t16.start();
t17.start();
t18.start();
t19.start();
t20.start();
}
}

100x
public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=100; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");
Loop3 t6 = new Loop3("Thread 6, Iteration ");
Loop3 t7 = new Loop3("Thread 7, Iteration ");
Loop3 t8 = new Loop3("Thread 8, Iteration ");
Loop3 t9 = new Loop3("Thread 9, Iteration ");
Loop3 t10 = new Loop3("Thread 10, Iteration ");
Loop3 t11 = new Loop3("Thread 11, Iteration ");
Loop3 t12 = new Loop3("Thread 12, Iteration ");
Loop3 t13 = new Loop3("Thread 13, Iteration ");
Loop3 t14 = new Loop3("Thread 14, Iteration ");
Loop3 t15 = new Loop3("Thread 15, Iteration ");
Loop3 t16 = new Loop3("Thread 16, Iteration ");
Loop3 t17 = new Loop3("Thread 17, Iteration ");
Loop3 t18 = new Loop3("Thread 18, Iteration ");
Loop3 t19 = new Loop3("Thread 19, Iteration ");
Loop3 t20 = new Loop3("Thread 20, Iteration ");
t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
t16.start();
t17.start();
t18.start();
t19.start();
t20.start();
}
}

1000x
public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=1000; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");
Loop3 t6 = new Loop3("Thread 6, Iteration ");
Loop3 t7 = new Loop3("Thread 7, Iteration ");
Loop3 t8 = new Loop3("Thread 8, Iteration ");
Loop3 t9 = new Loop3("Thread 9, Iteration ");
Loop3 t10 = new Loop3("Thread 10, Iteration ");
Loop3 t11 = new Loop3("Thread 11, Iteration ");
Loop3 t12 = new Loop3("Thread 12, Iteration ");
Loop3 t13 = new Loop3("Thread 13, Iteration ");
Loop3 t14 = new Loop3("Thread 14, Iteration ");
Loop3 t15 = new Loop3("Thread 15, Iteration ");
Loop3 t16 = new Loop3("Thread 16, Iteration ");
Loop3 t17 = new Loop3("Thread 17, Iteration ");
Loop3 t18 = new Loop3("Thread 18, Iteration ");
Loop3 t19 = new Loop3("Thread 19, Iteration ");
Loop3 t20 = new Loop3("Thread 20, Iteration ");
t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
t16.start();
t17.start();
t18.start();
t19.start();
t20.start();
}
}

10000x
public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=10000; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");
Loop3 t6 = new Loop3("Thread 6, Iteration ");
Loop3 t7 = new Loop3("Thread 7, Iteration ");
Loop3 t8 = new Loop3("Thread 8, Iteration ");
Loop3 t9 = new Loop3("Thread 9, Iteration ");
Loop3 t10 = new Loop3("Thread 10, Iteration ");
Loop3 t11 = new Loop3("Thread 11, Iteration ");
Loop3 t12 = new Loop3("Thread 12, Iteration ");
Loop3 t13 = new Loop3("Thread 13, Iteration ");
Loop3 t14 = new Loop3("Thread 14, Iteration ");
Loop3 t15 = new Loop3("Thread 15, Iteration ");
Loop3 t16 = new Loop3("Thread 16, Iteration ");
Loop3 t17 = new Loop3("Thread 17, Iteration ");
Loop3 t18 = new Loop3("Thread 18, Iteration ");
Loop3 t19 = new Loop3("Thread 19, Iteration ");
Loop3 t20 = new Loop3("Thread 20, Iteration ");
t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
t16.start();
t17.start();
t18.start();
t19.start();
t20.start();
}
}

1000000x
public class Loop3 extends Thread {
private String myName;

public Loop3(String name){


super(name);
myName = name;
}

public void run(){


long startTime = System.currentTimeMillis();
for (int i=1; i<=1000000; i++){
System.out.println(getName() + "(" + i + ")") ;
try{
sleep(10);
}
catch(InterruptedException e){
}
}
long endTime = System.currentTimeMillis();
System.out.println("TIME " + myName + ": " + (endTime-startTime) + "
Milisecond");
}

public static void main(String[] args){


Loop3 t1 = new Loop3("Thread 1, Iteration ");
Loop3 t2 = new Loop3("Thread 2, Iteration ");
Loop3 t3 = new Loop3("Thread 3, Iteration ");
Loop3 t4 = new Loop3("Thread 4, Iteration ");
Loop3 t5 = new Loop3("Thread 5, Iteration ");
Loop3 t6 = new Loop3("Thread 6, Iteration ");
Loop3 t7 = new Loop3("Thread 7, Iteration ");
Loop3 t8 = new Loop3("Thread 8, Iteration ");
Loop3 t9 = new Loop3("Thread 9, Iteration ");
Loop3 t10 = new Loop3("Thread 10, Iteration ");
Loop3 t11 = new Loop3("Thread 11, Iteration ");
Loop3 t12 = new Loop3("Thread 12, Iteration ");
Loop3 t13 = new Loop3("Thread 13, Iteration ");
Loop3 t14 = new Loop3("Thread 14, Iteration ");
Loop3 t15 = new Loop3("Thread 15, Iteration ");
Loop3 t16 = new Loop3("Thread 16, Iteration ");
Loop3 t17 = new Loop3("Thread 17, Iteration ");
Loop3 t18 = new Loop3("Thread 18, Iteration ");
Loop3 t19 = new Loop3("Thread 19, Iteration ");
Loop3 t20 = new Loop3("Thread 20, Iteration ");
t1.start();
t2.start();
t3.start();
t4.start();
t5.start();
t6.start();
t7.start();
t8.start();
t9.start();
t10.start();
t11.start();
t12.start();
t13.start();
t14.start();
t15.start();
t16.start();
t17.start();
t18.start();
t19.start();
t20.start();
}
}

Grafik
Loop 2
Interation
Thread 1000000
10x 100x 1000x 10000x x
1328160
253 210 211 240
5 Thread 4
1395837
228 214 223 163
10 Thread 1
1462504
204 1680 16229 157
15 Thread 8
1539271
205 1837 16617 162
20 Thread 5

Penjelasan Hasil :
Percobaan dimulai dari Loop 3 dengan 5 thread dan 10x, 100x, 1000x, 10000x, 1000000x Iteration.
Di 10x loop didapatkan waktu rata-rata 253ms.
Di 100x loop didapatkan waktu rata-rata 210ms.
Di 1000x loop didapatkan waktu rata-rata 211ms.
Di 10000x loop didapatkan waktu rata-rata 240ms.
Di 1000000x loop didapatkan waktu rata-rata 13281604ms.

Percobaan kedua dari Loop 3 dengan 10 thread dan 10x, 100x, 1000x, 10000x, 1000000x Iteration
Di 10x loop didapatkan waktu rata-rata 228ms.
Di 100x loop didapatkan waktu rata-rata 214ms.
Di 1000x loop didapatkan waktu rata-rata 223ms.
Di 10000x loop didapatkan waktu rata-rata 163ms.
Di 1000000x loop didapatkan waktu rata-rata 13958371ms.

Percobaan kedua dari Loop 1 dengan 15 thread dan 10x, 100x, 1000x, 10000x, 1000000x Iteration
Di 10x loop didapatkan waktu rata-rata 204ms.
Di 100x loop didapatkan waktu rata-rata 1680ms.
Di 1000x loop didapatkan waktu rata-rata 16229ms.
Di 10000x loop didapatkan waktu rata-rata 157ms.
Di 1000000x loop didapatkan waktu rata-rata 14625048ms

Percobaan kedua dari Loop 1 dengan 20 thread dan 10x, 100x, 1000x, 10000x, 1000000x Iteration
Di 10x loop didapatkan waktu rata-rata 205ms.
Di 100x loop didapatkan waktu rata-rata 1837ms.
Di 1000x loop didapatkan waktu rata-rata 16617ms.
Di 10000x loop didapatkan waktu rata-rata 162ms.
Di 1000000x loop didapatkan waktu rata-rata 15392715ms

You might also like