[JAVA100 example]060, inheritance thread

Source: Internet
Author: User
Tags inheritance thread class

/**
* <p>title: Inheriting thread, implementing threading </p>
* <p>description: Implementing its Run method by inheriting the thread class, implementing its own thread </p>
* <p>copyright:copyright (c) 2003</p>
* <p>Filename:oneThread.java</p>
* @version 1.0
*/
public class Onethread extends Thread {
/**
*<br> Method Description: Constructor, this class does not use
*<br& gt; input parameters:
*<br> return type:
*/
Public onethread () {

}
/**
*<br> method Description: Inherit the method that the thread class must implement. Run this method
*<br> input parameter when calling the Start method:
*<br> return type:
*/
public void Run () {
System.out.println (" ... onethread begining ...................... ...
int flag = 0;
while (true) {
if (flag==20) {
System.out.println ("\n...............onethread" ...). ");
break;   
}
for (int i=0;i<flag;i++)
System.out.print ("*");
System.out.println ("");
flag++;  
try{
//sleep 0.1 seconds
Sleeping (MB);
}catch (Exception e) {
}
}

/**
*<br> Method Description: Main method. Start this thread
*<br> input parameters:
*<br> return type:
*/
public static void Main (String args[]) {
New Onethread () . Start ();
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.