www.baidu.com

JavaCode--我爱你,芳儿

JavaStudy--我爱你,芳儿

关于线程学习打的代码

关于线程学习打的代码 //by EditPlus
class ThreadTest extends Thread
{
    
public void run()
    {
        System.out.println(
"the thread is running!");
    }
    
public void run(String s)
    {
        System.out.println(
"thethread is :" + s);
    }
    
public static void main(String[] args)
    {
        ThreadTest threadTest1 
= new ThreadTest();
        Thread thread1 
= new Thread(threadTest1);
        thread1.start();
        
for(int i  = 0; i <= 1100; i++);
        
//when you write the i++,you should not write it like this:i ++..there is no space between the i and the ++!!be careful!
        threadTest1.run("wo ai ni babe!");
    }

}

public class PingPong extends Thread
{
    
private String word;
    
private int delay;
    
public PingPong(String s,int i)
    {
        word 
= s;
        delay 
= i;
    }
    
public void run()
    {
        
try 
        {
            
forint i = 1; i <= 100; i++)
            {
                System.out.println(word 
+ "is what i want!");
                Thread.sleep(delay);
            }
        }
        
catch(InterruptedException e)
        {
            
return;
        }
    }
    
public static void main(String argv[])
    {
        
new PingPong("wo",30).start();
        
new PingPong("wod",100).start();
    }

}


public class ThreadTest1 implements Runnable
{
    
public ThreadTest1()
    {
        System.out.print(
"babe!");
    }
    
public ThreadTest1(String s)
    {
        System.out.print(
"BABE " + s);
    }
    
public void run()
    {
        System.out.println(
"what I want is your heart and your body!");
    }
    
public static void main(String[] args)
    {
        ThreadTest1 th 
= new ThreadTest1();
        Thread thread 
= new Thread(th);
        ThreadTest1 th1 
= new ThreadTest1("Wjf");
        Thread thread1 
= new Thread(th1);
        thread.start();
        thread1.start();
    }
}


 

芳儿宝贝.我爱你

posted on 2007-12-08 18:01 wǒ愛伱--咾婆 阅读(196) 评论(0)  编辑  收藏 所属分类: JavaCode


只有注册用户登录后才能发表评论。


网站导航:
 

导航

统计

公告

芳儿宝贝.我爱你


黑客基地
http://www.hackbase.com
全球最大的黑客门户网站


 最近在读的书:

常用链接

留言簿(1)

随笔分类(37)

JavaCode

搜索

积分与排名

最新评论

阅读排行榜

评论排行榜