ballfly
发贴: 7
积分: 0
|
于 2005-10-10 14:14
//实现双线程,分别从坐标(0,0)(0,50)画到(100,0)(100,50),能编译但无显示
import java.applet.*; import java.awt.*; public class Abc extends Applet implements Runnable { Thread th1; Thread th2; int parsetime; int y; public Abc(int a,int b) {parsetime=a;y=b;} public void start() { th1=new Thread(new Abc(1000,0)); th1.start(); th2=new Thread(new Abc(2000,50)); th2.start(); } public void run() { repaint(); } public void paint(Graphics g) { try { for(int a=0;a<=100;a++) {g.drawLine(a,y,a+1,y); th1.sleep(parsetime);} } catch(InterruptedException e){} } }
|