thread.jav
来自「有关java的源程序,为讲授java程序设计课程使用」· JAV 代码 · 共 58 行
JAV
58 行
public class MyForm extends Form
{ public MyForm()
{ initForm();
Application.createThread(new MethodInvoker(MyThread),Thread.NORM_PRIORITY);
}
private void MyThread()
{
Graphics g=this.createGraphics();
for(int i=0; i<=200;i++)
{
g.drawString("i="+new Integer(i).toString(),100,100);
}
}
}
_________________________________________________________________________
public class MyForm extends Form implements Runnable
{
public MyForm()
{
initForm();
new Thread(this).start();
}
public void run()
{
Graphics g=this.createGraphics();
for(int i=0; i<2000;i++)
{
g.drawString("i="+new Integer(i).toString(),100,100);
}
}
}
________________________________________________________________________
public class MyForm extends Form
{ public MyForm()
{
initForm();
new MyThread(this).start();
}
}
class MyThread extends Thread
{
MyForm thisForm;
MyThread(MyForm formObj)
{
thisForm=formObj;
}
public void run()
{
Graphics g=thisForm.createGraphics();
for(int i=0;i<=2000;i++)
{
g.drawString("i="+new Integer(i).toString(),100,100);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?