casper. Powered by Blogger.

Blog ini bertujuan untuk share ilmu dan pengetahuan. Semua source/aplikasi di blog ini bebas disebar dan mencamtumkan sumber "fandy-alfa.blogspot.com".

RSS

Multi Threading Java

contoh thread di java, ...\\

lanjut sob...

/*
 * Author : Fandy Adam
 * Email  : fandy_alfa@yahoo.com
 * Email  : casperadam91@gmail.com
 * Blog   : fandy-alfa.blogspot.com
 * IDE    : netbeans 7.1.x
 * NOTEBOOK ACER ASPIRE 4738
 */
package app.imageprocessing.thread;

import java.awt.image.BufferedImage;

/**
 *
 * @author Fandy
 */
public class MyThread implements Runnable{

    private BufferedImage image;
    private int x;
    private app.imageprocessing.thread.ImagePanel panel;

    public MyThread(BufferedImage image, int x, app.imageprocessing.thread.ImagePanel panel) {
        this.image = image;
        this.x = x;
        this.panel = panel;
    }
   
    public void run() {
        int y=0;
        while (y < image.getHeight()) {
            try {
                Thread.sleep(100);
            } catch (InterruptedException ex) { }
            panel.setYellow(x, y);
            y++;
        }
    }
   
}
 
  • Digg
  • Del.icio.us
  • StumbleUpon
  • Reddit
  • RSS

0 comments:

Post a Comment