zoukankan      html  css  js  c++  java
  • TestNG多线程测试-注解方式实现

    用@Test(invocationCount = x,threadPoolSize = y)声明,
    invocationCount表示执行次数,threadPoolSize表示线程池大小。
    package com.janson.multiThread;
    
    import org.testng.annotations.Test;
    
    public class MultiThreadOnAnnotation {
    
        /**
         * 多线程测试,没有关联的用例可以使用多线程,减少执行时间
         * 以下演示3个线程同时运行,共执行10次
         */
        @Test(invocationCount = 10,threadPoolSize = 3)
        public void test() {
            System.out.println("*************hello world**************");
            System.out.printf("Thread Id : %s%n",Thread.currentThread().getId());
        }
    }

    运行结果:

    *************hello world**************
    *************hello world**************
    Thread Id : 13
    *************hello world**************
    Thread Id : 12
    Thread Id : 11
    *************hello world**************
    *************hello world**************
    Thread Id : 11
    Thread Id : 13
    *************hello world**************
    Thread Id : 12
    *************hello world**************
    Thread Id : 11
    *************hello world**************
    Thread Id : 13
    *************hello world**************
    *************hello world**************
    Thread Id : 11
    Thread Id : 12
    
    ===============================================
    Default Suite
    Total tests run: 10, Failures: 0, Skips: 0
    ===============================================
    
    
    Process finished with exit code 0
  • 相关阅读:
    封装好的AFN网络请求框架和MBProgress
    iOS定时器的使用
    iOS去除导航栏和tabbar的1px横线
    移动端加解密
    改变字符串中部分字符传的字体大小和颜色
    关于NSLog
    ipad开发:二维码扫描,摄像头旋转角度问题解决办法
    iOS-图文表并茂,手把手教你GCD
    计算富文本的高度
    jsp打印
  • 原文地址:https://www.cnblogs.com/janson071/p/10005986.html
Copyright © 2011-2022 走看看