JUnit test class testing problems with multithreading

Source: Internet
Author: User

    @Test public    void Testsychronized () throws interruptedexception {        thread t1 = new Thread (new Runnable () {            @Ov Erride public            Void Run () {                /*system.out.println ("I Hate U");                Synchronized (this) {                    System.out.println ("I love U");                } *                /while (true) {                    System.out.println ("Child Thread");}}        );        T1.setdaemon (false);        T1.start ();        Thread.Sleep (+);        SYSTEM.OUT.PRINTLN ("SSS");    

Using JUnit to execute this code, the child thread is also forced to terminate after the test method executes, and the main test does not (of course, if the child thread is set up as a daemon, it will be forced to exit after the main thread executes System.exit (0)).

Answer quote from http://bbs.csdn.net/topics/391807147, thank you very much

JUnit test class testing problems with multithreading

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.