网站首页 新闻首页 网页设计图形动画软件编程网站开发办公软件操作系统数据库网络技术认证考试范文资料黑客攻防 书籍教程 进入论坛

Tshow

http://www.diybl.com/ 2008-2-21  网络 点击:  [ 评论 ]
文章搜索:    【点击打包该文章】

import java.util.*;

public class Tshow{
  Runnable r1 = new t1();
  Runnable r2 = new t2();
  Thread th1 = new Thread(r1);
  Thread th2 = new Thread(r2);
 public void GetInts() throws Exception{
  System.out.println("Int1=" + Integer.toString(((t1)r1).getX()) + "\t\tIntY=" + Integer.toString(((t2)r2).getY()));
  Thread.sleep(100);
  GetInts();
 }
 public void loop(){
  try{
   th1.start();
   th2.start();
   GetInts();
  }catch(Exception e){System.out.println(e);}
 }
 public static void main(String agrt[]){
  Tshow k = new Tshow();
  k.loop();
 }
}

class t1 implements Runnable{
 int intX = 0;
 public void run(){
  try{
  intX++;
  Thread.sleep(300);
  run();
  }catch(Exception e){}
 }
 public int getX(){
  return intX;
 }
}
class t2 implements Runnable{
 int intY = 1000000;
 public void run(){
  try{
  intY--;
  Thread.sleep(100);
  run();
  }catch(Exception e){}
 }
 public int getY(){
  return intY;
 }



欢迎光临DIY部落,点击这里查看更多文章教程   【点击打包该文章】
如果图片或页面不能正常显示请点击这里 站内搜索:   
上一篇文章:一些错误
下一篇文章:关于Java Servlet的Filter 技术

文章评论

请您留言