当前位置: 技术问答>java相关
为什么在javaBean中的线程不能运行?(代码如下)
来源: 互联网 发布时间:2015-01-01
本文导语: package test2; import java.awt.*; public class indexBean { public int j=1; private Ball b ; public void setint() { b = new Ball(j); b.start(); } public int getint(){ return b.returntest() ; } } class Ball extends T...
package test2;
import java.awt.*;
public class indexBean
{
public int j=1;
private Ball b ;
public void setint()
{ b = new Ball(j);
b.start();
}
public int getint(){
return b.returntest() ;
}
}
class Ball extends Thread
{
private int test;
public Ball(int j) {test=j;}
public void run()
{ try
{
for (int i = 1; i
import java.awt.*;
public class indexBean
{
public int j=1;
private Ball b ;
public void setint()
{ b = new Ball(j);
b.start();
}
public int getint(){
return b.returntest() ;
}
}
class Ball extends Thread
{
private int test;
public Ball(int j) {test=j;}
public void run()
{ try
{
for (int i = 1; i