015.5 common thread usage (interview questions), 015.5 thread usage questions

Source: Internet
Author: User

015.5 common thread usage (interview questions), 015.5 thread usage questions

Content: Example

Class ThreadTest {public static void main (String [] args) {/* new Thread () {public void run () {for (int x = 0; x <40; x ++) {System. out. println (Thread. currentThread (). getName () + "... X .... "+ x );}}}. start (); Runnable r = new Runnable () {public void run () {for (int x = 0; x <40; x ++) {System. out. println (Thread. currentThread (). getName () + "... Y .... "+ x) ;}}; new Thread (r ). start (); for (int x = 0; x <40; x ++) {S Ystem. out. println (Thread. currentThread (). getName () + "... Z .... "+ x);} System. out. println ("Hello World! "); * // Interview question: new Thread (new Runnable () {public void run () {System. out. println ("runnable run") ;}} {public void run () {System. out. println ("subthread run"); // run. }}. Start () ;}/ * class Thread {private Runnable r; Thread (Runnable r) {this. r = r;} public void run () {if (r! = Null) {r. run () ;}} public void start () {run () ;}} class SubThread extends Thread {public void run () {System. out. println ("subthread run") ;}} Runnable r = new Runnable () {public void run () {System. out. println ("runnable run") ;}} SubThread t = new SubThread (r); t. 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.