Java多线程顺序执行

 一直以为同步的时候只要锁住对象就能顺序执行了

但是这样是错误的!两个线程还是交替执行! 

package com.ps.uzkefu.util;

/**
 * Created by Administrator on 2018/6/28 0028.
 */
public class Test implements  Runnable{



    @Override
    public void run() {
        synchronized (this) {
            for (int n = 0; n < 10; n++) {
                System.out.println(Thread.currentThread().getName() + ":" + n);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    public static void main(String[] args) {
        //两个线程锁住的this对象不是同一个,所以导致交叉执行
        Test t = new Test();
        Test t2 = new Test();
        Thread thread1 = new Thread(t);
        Thread thread2 = new Thread(t2);
        thread1.start();
        thread2.start();

    }
}

上面这个锁是不正确的,两个线程锁住的this对象不是同一个,所以导致交叉执行。

执行结果如下,线程0 和线程1 交叉执行

D:\java\jdk\bin\java -Didea.launcher.port=7542 "-Didea.launcher.bin.path=D:\JetBrains\IntelliJ IDEA 2016.3.4\bin" -Dfile.encoding=UTF-8 -classpath "D:\java\jdk\jre\lib\charsets.jar;D:\java\jdk\jre\lib\deploy.jar;D:\java\jdk\jre\lib\ext\access-bridge-64.jar;D:\java\jdk\jre\lib\ext\cldrdata.jar;D:\java\jdk\jre\lib\ext\dnsns.jar;D:\java\jdk\jre\lib\ext\jaccess.jar;D:\java\jdk\jre\lib\ext\jfxrt.jar;D:\java\jdk\jre\lib\ext\localedata.jar;D:\java\jdk\jre\lib\ext\nashorn.jar;D:\java\jdk\jre\lib\ext\sunec.jar;D:\java\jdk\jre\lib\ext\sunjce_provider.jar;D:\java\jdk\jre\lib\ext\sunmscapi.jar;D:\java\jdk\jre\lib\ext\sunpkcs11.jar;D:\java\jdk\jre\lib\ext\zipfs.jar;D:\java\jdk\jre\lib\javaws.jar;D:\java\jdk\jre\lib\jce.jar;D:\java\jdk\jre\lib\jfr.jar;D:\java\jdk\jre\lib\jfxswt.jar;D:\java\jdk\jre\lib\jsse.jar;D:\java\jdk\jre\lib\management-agent.jar;D:\java\jdk\jre\lib\plugin.jar;D:\java\jdk\jre\lib\resources.jar;D:\java\jdk\jre\lib\rt.jar;E:\workspaces\ps\uzkefu\target\classes;F:\apache\maven3.2.1\repository\com\baomidou\mybatis-plus\2.3\mybatis-plus-2.3.jar;F:\apache\maven3.2.1\repository\com\baomidou\mybatis-plus-support\2.3\mybatis-plus-support-2.3.jar;F:\apache\maven3.2.1\repository\com\baomidou\mybatis-plus-core\2.3\mybatis-plus-core-2.3.jar;F:\apache\maven3.2.1\repository\com\github\jsqlparser\jsqlparser\1.1\jsqlparser-1.1.jar;F:\apache\maven3.2.1\repository\org\mybatis\mybatis-spring\1.3.2\mybatis-spring-1.3.2.jar;F:\apache\maven3.2.1\repository\org\mybatis\mybatis\3.4.6\mybatis-3.4.6.jar;F:\apache\maven3.2.1\repository\com\baomidou\mybatis-plus-generate\2.3\mybatis-plus-generate-2.3.jar;F:\apache\maven3.2.1\repository\com\baomidou\mybatis-plus-boot-starter\2.3\mybatis-plus-boot-starter-2.3.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-autoconfigure\2.0.3.RELEASE\spring-boot-autoconfigure-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\commons-beanutils\commons-beanutils\1.9.3\commons-beanutils-1.9.3.jar;F:\apache\maven3.2.1\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;F:\apache\maven3.2.1\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;F:\apache\maven3.2.1\repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;F:\apache\maven3.2.1\repository\com\aliyun\aliyun-java-sdk-core\3.7.1\aliyun-java-sdk-core-3.7.1.jar;F:\apache\maven3.2.1\repository\com\aliyun\aliyun-java-sdk-dysmsapi\1.1.0\aliyun-java-sdk-dysmsapi-1.1.0.jar;F:\apache\maven3.2.1\repository\org\json\json\20180130\json-20180130.jar;F:\apache\maven3.2.1\repository\com\alibaba\fastjson\1.2.37\fastjson-1.2.37.jar;F:\apache\maven3.2.1\repository\com\fasterxml\jackson\core\jackson-core\2.9.6\jackson-core-2.9.6.jar;F:\apache\maven3.2.1\repository\com\alibaba\druid\1.1.9\druid-1.1.9.jar;F:\apache\maven3.2.1\repository\mysql\mysql-connector-java\5.1.21\mysql-connector-java-5.1.21.jar;F:\apache\maven3.2.1\repository\com\alibaba\druid-spring-boot-starter\1.1.9\druid-spring-boot-starter-1.1.9.jar;F:\apache\maven3.2.1\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-starter-jdbc\2.0.3.RELEASE\spring-boot-starter-jdbc-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\com\zaxxer\HikariCP\2.7.9\HikariCP-2.7.9.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-jdbc\5.0.7.RELEASE\spring-jdbc-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-beans\5.0.7.RELEASE\spring-beans-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-tx\5.0.7.RELEASE\spring-tx-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-configuration-processor\2.0.3.RELEASE\spring-boot-configuration-processor-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-starter-tomcat\2.0.3.RELEASE\spring-boot-starter-tomcat-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;F:\apache\maven3.2.1\repository\org\apache\tomcat\embed\tomcat-embed-core\8.5.31\tomcat-embed-core-8.5.31.jar;F:\apache\maven3.2.1\repository\org\apache\tomcat\embed\tomcat-embed-el\8.5.31\tomcat-embed-el-8.5.31.jar;F:\apache\maven3.2.1\repository\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.31\tomcat-embed-websocket-8.5.31.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-core\5.0.7.RELEASE\spring-core-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-jcl\5.0.7.RELEASE\spring-jcl-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-starter-web\2.0.3.RELEASE\spring-boot-starter-web-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-starter-json\2.0.3.RELEASE\spring-boot-starter-json-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.6\jackson-datatype-jdk8-2.9.6.jar;F:\apache\maven3.2.1\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.6\jackson-datatype-jsr310-2.9.6.jar;F:\apache\maven3.2.1\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.6\jackson-module-parameter-names-2.9.6.jar;F:\apache\maven3.2.1\repository\org\hibernate\validator\hibernate-validator\6.0.10.Final\hibernate-validator-6.0.10.Final.jar;F:\apache\maven3.2.1\repository\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;F:\apache\maven3.2.1\repository\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;F:\apache\maven3.2.1\repository\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-web\5.0.7.RELEASE\spring-web-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-webmvc\5.0.7.RELEASE\spring-webmvc-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-expression\5.0.7.RELEASE\spring-expression-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-starter\2.0.3.RELEASE\spring-boot-starter-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-starter-logging\2.0.3.RELEASE\spring-boot-starter-logging-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;F:\apache\maven3.2.1\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;F:\apache\maven3.2.1\repository\org\apache\logging\log4j\log4j-to-slf4j\2.10.0\log4j-to-slf4j-2.10.0.jar;F:\apache\maven3.2.1\repository\org\apache\logging\log4j\log4j-api\2.10.0\log4j-api-2.10.0.jar;F:\apache\maven3.2.1\repository\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;F:\apache\maven3.2.1\repository\org\yaml\snakeyaml\1.19\snakeyaml-1.19.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot\2.0.3.RELEASE\spring-boot-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-context\5.0.7.RELEASE\spring-context-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-devtools\2.0.3.RELEASE\spring-boot-devtools-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-starter-aop\2.0.3.RELEASE\spring-boot-starter-aop-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-aop\5.0.7.RELEASE\spring-aop-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\aspectj\aspectjweaver\1.8.13\aspectjweaver-1.8.13.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-starter-freemarker\2.0.3.RELEASE\spring-boot-starter-freemarker-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\org\freemarker\freemarker\2.3.28\freemarker-2.3.28.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-context-support\5.0.7.RELEASE\spring-context-support-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\redisson\redisson\3.7.2\redisson-3.7.2.jar;F:\apache\maven3.2.1\repository\io\netty\netty-common\4.1.25.Final\netty-common-4.1.25.Final.jar;F:\apache\maven3.2.1\repository\io\netty\netty-codec\4.1.25.Final\netty-codec-4.1.25.Final.jar;F:\apache\maven3.2.1\repository\io\netty\netty-buffer\4.1.25.Final\netty-buffer-4.1.25.Final.jar;F:\apache\maven3.2.1\repository\io\netty\netty-transport\4.1.25.Final\netty-transport-4.1.25.Final.jar;F:\apache\maven3.2.1\repository\io\netty\netty-resolver\4.1.25.Final\netty-resolver-4.1.25.Final.jar;F:\apache\maven3.2.1\repository\io\netty\netty-resolver-dns\4.1.25.Final\netty-resolver-dns-4.1.25.Final.jar;F:\apache\maven3.2.1\repository\io\netty\netty-codec-dns\4.1.25.Final\netty-codec-dns-4.1.25.Final.jar;F:\apache\maven3.2.1\repository\io\netty\netty-handler\4.1.25.Final\netty-handler-4.1.25.Final.jar;F:\apache\maven3.2.1\repository\javax\cache\cache-api\1.1.0\cache-api-1.1.0.jar;F:\apache\maven3.2.1\repository\io\projectreactor\reactor-core\3.1.8.RELEASE\reactor-core-3.1.8.RELEASE.jar;F:\apache\maven3.2.1\repository\org\reactivestreams\reactive-streams\1.0.2\reactive-streams-1.0.2.jar;F:\apache\maven3.2.1\repository\com\fasterxml\jackson\dataformat\jackson-dataformat-yaml\2.9.6\jackson-dataformat-yaml-2.9.6.jar;F:\apache\maven3.2.1\repository\com\fasterxml\jackson\core\jackson-databind\2.9.6\jackson-databind-2.9.6.jar;F:\apache\maven3.2.1\repository\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;F:\apache\maven3.2.1\repository\net\bytebuddy\byte-buddy\1.7.11\byte-buddy-1.7.11.jar;F:\apache\maven3.2.1\repository\org\jodd\jodd-bean\3.7.1\jodd-bean-3.7.1.jar;F:\apache\maven3.2.1\repository\org\jodd\jodd-core\3.7.1\jodd-core-3.7.1.jar;F:\apache\maven3.2.1\repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;F:\apache\maven3.2.1\repository\xml-apis\xml-apis\1.4.01\xml-apis-1.4.01.jar;F:\apache\maven3.2.1\repository\org\apache\velocity\velocity-engine-core\2.0\velocity-engine-core-2.0.jar;F:\apache\maven3.2.1\repository\org\apache\commons\commons-lang3\3.7\commons-lang3-3.7.jar;F:\apache\maven3.2.1\repository\org\apache\httpcomponents\httpclient\4.5.2\httpclient-4.5.2.jar;F:\apache\maven3.2.1\repository\org\apache\httpcomponents\httpcore\4.4.9\httpcore-4.4.9.jar;F:\apache\maven3.2.1\repository\commons-codec\commons-codec\1.11\commons-codec-1.11.jar;F:\apache\maven3.2.1\repository\org\apache\httpcomponents\httpclient-cache\4.5.2\httpclient-cache-4.5.2.jar;D:\JetBrains\IntelliJ IDEA 2016.3.4\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain com.ps.uzkefu.util.Test
Thread-0:0
Thread-1:0
Thread-1:1
Thread-0:1
Thread-0:2
Thread-1:2
Thread-0:3
Thread-1:3
Thread-1:4
Thread-0:4
Thread-0:5
Thread-1:5
Thread-0:6
Thread-1:6
Thread-1:7
Thread-0:7
Thread-0:8
Thread-1:8
Thread-1:9
Thread-0:9

Process finished with exit code 0

 

 

 

 

下面是线程同步执行的代码

 

package com.ps.uzkefu.util;

/**
 * Created by Administrator on 2018/6/28 0028.
 */
public class Test1 implements Runnable{

    @Override
    public void run() {
        synchronized (this) {
            for (int n = 0; n < 10; n++) {
                System.out.println(Thread.currentThread().getName()+":" + n);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    }


    public static void main(String[] args) {
        Test1 t = new Test1();
        //线程1 和线程2 共享 Tets1 对象   synchronized 关键字实现同步 顺序执行
        Thread thread1 = new Thread(t);
        Thread thread2 = new Thread(t);
        thread1.start();
        thread2.start();




    }



}

 

执行结果如下

 

 

D:\java\jdk\bin\java -Didea.launcher.port=7544 "-Didea.launcher.bin.path=D:\JetBrains\IntelliJ IDEA 2016.3.4\bin" -Dfile.encoding=UTF-8 -classpath "D:\java\jdk\jre\lib\charsets.jar;D:\java\jdk\jre\lib\deploy.jar;D:\java\jdk\jre\lib\ext\access-bridge-64.jar;D:\java\jdk\jre\lib\ext\cldrdata.jar;D:\java\jdk\jre\lib\ext\dnsns.jar;D:\java\jdk\jre\lib\ext\jaccess.jar;D:\java\jdk\jre\lib\ext\jfxrt.jar;D:\java\jdk\jre\lib\ext\localedata.jar;D:\java\jdk\jre\lib\ext\nashorn.jar;D:\java\jdk\jre\lib\ext\sunec.jar;D:\java\jdk\jre\lib\ext\sunjce_provider.jar;D:\java\jdk\jre\lib\ext\sunmscapi.jar;D:\java\jdk\jre\lib\ext\sunpkcs11.jar;D:\java\jdk\jre\lib\ext\zipfs.jar;D:\java\jdk\jre\lib\javaws.jar;D:\java\jdk\jre\lib\jce.jar;D:\java\jdk\jre\lib\jfr.jar;D:\java\jdk\jre\lib\jfxswt.jar;D:\java\jdk\jre\lib\jsse.jar;D:\java\jdk\jre\lib\management-agent.jar;D:\java\jdk\jre\lib\plugin.jar;D:\java\jdk\jre\lib\resources.jar;D:\java\jdk\jre\lib\rt.jar;E:\workspaces\ps\uzkefu\target\classes;F:\apache\maven3.2.1\repository\com\baomidou\mybatis-plus\2.3\mybatis-plus-2.3.jar;F:\apache\maven3.2.1\repository\com\baomidou\mybatis-plus-support\2.3\mybatis-plus-support-2.3.jar;F:\apache\maven3.2.1\repository\com\baomidou\mybatis-plus-core\2.3\mybatis-plus-core-2.3.jar;F:\apache\maven3.2.1\repository\com\github\jsqlparser\jsqlparser\1.1\jsqlparser-1.1.jar;F:\apache\maven3.2.1\repository\org\mybatis\mybatis-spring\1.3.2\mybatis-spring-1.3.2.jar;F:\apache\maven3.2.1\repository\org\mybatis\mybatis\3.4.6\mybatis-3.4.6.jar;F:\apache\maven3.2.1\repository\com\baomidou\mybatis-plus-generate\2.3\mybatis-plus-generate-2.3.jar;F:\apache\maven3.2.1\repository\com\baomidou\mybatis-plus-boot-starter\2.3\mybatis-plus-boot-starter-2.3.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-autoconfigure\2.0.3.RELEASE\spring-boot-autoconfigure-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\commons-beanutils\commons-beanutils\1.9.3\commons-beanutils-1.9.3.jar;F:\apache\maven3.2.1\repository\commons-logging\commons-logging\1.2\commons-logging-1.2.jar;F:\apache\maven3.2.1\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;F:\apache\maven3.2.1\repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;F:\apache\maven3.2.1\repository\com\aliyun\aliyun-java-sdk-core\3.7.1\aliyun-java-sdk-core-3.7.1.jar;F:\apache\maven3.2.1\repository\com\aliyun\aliyun-java-sdk-dysmsapi\1.1.0\aliyun-java-sdk-dysmsapi-1.1.0.jar;F:\apache\maven3.2.1\repository\org\json\json\20180130\json-20180130.jar;F:\apache\maven3.2.1\repository\com\alibaba\fastjson\1.2.37\fastjson-1.2.37.jar;F:\apache\maven3.2.1\repository\com\fasterxml\jackson\core\jackson-core\2.9.6\jackson-core-2.9.6.jar;F:\apache\maven3.2.1\repository\com\alibaba\druid\1.1.9\druid-1.1.9.jar;F:\apache\maven3.2.1\repository\mysql\mysql-connector-java\5.1.21\mysql-connector-java-5.1.21.jar;F:\apache\maven3.2.1\repository\com\alibaba\druid-spring-boot-starter\1.1.9\druid-spring-boot-starter-1.1.9.jar;F:\apache\maven3.2.1\repository\org\slf4j\slf4j-api\1.7.25\slf4j-api-1.7.25.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-starter-jdbc\2.0.3.RELEASE\spring-boot-starter-jdbc-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\com\zaxxer\HikariCP\2.7.9\HikariCP-2.7.9.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-jdbc\5.0.7.RELEASE\spring-jdbc-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-beans\5.0.7.RELEASE\spring-beans-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-tx\5.0.7.RELEASE\spring-tx-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-configuration-processor\2.0.3.RELEASE\spring-boot-configuration-processor-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-starter-tomcat\2.0.3.RELEASE\spring-boot-starter-tomcat-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\javax\annotation\javax.annotation-api\1.3.2\javax.annotation-api-1.3.2.jar;F:\apache\maven3.2.1\repository\org\apache\tomcat\embed\tomcat-embed-core\8.5.31\tomcat-embed-core-8.5.31.jar;F:\apache\maven3.2.1\repository\org\apache\tomcat\embed\tomcat-embed-el\8.5.31\tomcat-embed-el-8.5.31.jar;F:\apache\maven3.2.1\repository\org\apache\tomcat\embed\tomcat-embed-websocket\8.5.31\tomcat-embed-websocket-8.5.31.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-core\5.0.7.RELEASE\spring-core-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-jcl\5.0.7.RELEASE\spring-jcl-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-starter-web\2.0.3.RELEASE\spring-boot-starter-web-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-starter-json\2.0.3.RELEASE\spring-boot-starter-json-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.9.6\jackson-datatype-jdk8-2.9.6.jar;F:\apache\maven3.2.1\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.9.6\jackson-datatype-jsr310-2.9.6.jar;F:\apache\maven3.2.1\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.9.6\jackson-module-parameter-names-2.9.6.jar;F:\apache\maven3.2.1\repository\org\hibernate\validator\hibernate-validator\6.0.10.Final\hibernate-validator-6.0.10.Final.jar;F:\apache\maven3.2.1\repository\javax\validation\validation-api\2.0.1.Final\validation-api-2.0.1.Final.jar;F:\apache\maven3.2.1\repository\org\jboss\logging\jboss-logging\3.3.2.Final\jboss-logging-3.3.2.Final.jar;F:\apache\maven3.2.1\repository\com\fasterxml\classmate\1.3.4\classmate-1.3.4.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-web\5.0.7.RELEASE\spring-web-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-webmvc\5.0.7.RELEASE\spring-webmvc-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-expression\5.0.7.RELEASE\spring-expression-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-starter\2.0.3.RELEASE\spring-boot-starter-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-starter-logging\2.0.3.RELEASE\spring-boot-starter-logging-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;F:\apache\maven3.2.1\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;F:\apache\maven3.2.1\repository\org\apache\logging\log4j\log4j-to-slf4j\2.10.0\log4j-to-slf4j-2.10.0.jar;F:\apache\maven3.2.1\repository\org\apache\logging\log4j\log4j-api\2.10.0\log4j-api-2.10.0.jar;F:\apache\maven3.2.1\repository\org\slf4j\jul-to-slf4j\1.7.25\jul-to-slf4j-1.7.25.jar;F:\apache\maven3.2.1\repository\org\yaml\snakeyaml\1.19\snakeyaml-1.19.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot\2.0.3.RELEASE\spring-boot-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-context\5.0.7.RELEASE\spring-context-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-devtools\2.0.3.RELEASE\spring-boot-devtools-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-starter-aop\2.0.3.RELEASE\spring-boot-starter-aop-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-aop\5.0.7.RELEASE\spring-aop-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\aspectj\aspectjweaver\1.8.13\aspectjweaver-1.8.13.jar;F:\apache\maven3.2.1\repository\org\springframework\boot\spring-boot-starter-freemarker\2.0.3.RELEASE\spring-boot-starter-freemarker-2.0.3.RELEASE.jar;F:\apache\maven3.2.1\repository\org\freemarker\freemarker\2.3.28\freemarker-2.3.28.jar;F:\apache\maven3.2.1\repository\org\springframework\spring-context-support\5.0.7.RELEASE\spring-context-support-5.0.7.RELEASE.jar;F:\apache\maven3.2.1\repository\org\redisson\redisson\3.7.2\redisson-3.7.2.jar;F:\apache\maven3.2.1\repository\io\netty\netty-common\4.1.25.Final\netty-common-4.1.25.Final.jar;F:\apache\maven3.2.1\repository\io\netty\netty-codec\4.1.25.Final\netty-codec-4.1.25.Final.jar;F:\apache\maven3.2.1\repository\io\netty\netty-buffer\4.1.25.Final\netty-buffer-4.1.25.Final.jar;F:\apache\maven3.2.1\repository\io\netty\netty-transport\4.1.25.Final\netty-transport-4.1.25.Final.jar;F:\apache\maven3.2.1\repository\io\netty\netty-resolver\4.1.25.Final\netty-resolver-4.1.25.Final.jar;F:\apache\maven3.2.1\repository\io\netty\netty-resolver-dns\4.1.25.Final\netty-resolver-dns-4.1.25.Final.jar;F:\apache\maven3.2.1\repository\io\netty\netty-codec-dns\4.1.25.Final\netty-codec-dns-4.1.25.Final.jar;F:\apache\maven3.2.1\repository\io\netty\netty-handler\4.1.25.Final\netty-handler-4.1.25.Final.jar;F:\apache\maven3.2.1\repository\javax\cache\cache-api\1.1.0\cache-api-1.1.0.jar;F:\apache\maven3.2.1\repository\io\projectreactor\reactor-core\3.1.8.RELEASE\reactor-core-3.1.8.RELEASE.jar;F:\apache\maven3.2.1\repository\org\reactivestreams\reactive-streams\1.0.2\reactive-streams-1.0.2.jar;F:\apache\maven3.2.1\repository\com\fasterxml\jackson\dataformat\jackson-dataformat-yaml\2.9.6\jackson-dataformat-yaml-2.9.6.jar;F:\apache\maven3.2.1\repository\com\fasterxml\jackson\core\jackson-databind\2.9.6\jackson-databind-2.9.6.jar;F:\apache\maven3.2.1\repository\com\fasterxml\jackson\core\jackson-annotations\2.9.0\jackson-annotations-2.9.0.jar;F:\apache\maven3.2.1\repository\net\bytebuddy\byte-buddy\1.7.11\byte-buddy-1.7.11.jar;F:\apache\maven3.2.1\repository\org\jodd\jodd-bean\3.7.1\jodd-bean-3.7.1.jar;F:\apache\maven3.2.1\repository\org\jodd\jodd-core\3.7.1\jodd-core-3.7.1.jar;F:\apache\maven3.2.1\repository\dom4j\dom4j\1.6.1\dom4j-1.6.1.jar;F:\apache\maven3.2.1\repository\xml-apis\xml-apis\1.4.01\xml-apis-1.4.01.jar;F:\apache\maven3.2.1\repository\org\apache\velocity\velocity-engine-core\2.0\velocity-engine-core-2.0.jar;F:\apache\maven3.2.1\repository\org\apache\commons\commons-lang3\3.7\commons-lang3-3.7.jar;F:\apache\maven3.2.1\repository\org\apache\httpcomponents\httpclient\4.5.2\httpclient-4.5.2.jar;F:\apache\maven3.2.1\repository\org\apache\httpcomponents\httpcore\4.4.9\httpcore-4.4.9.jar;F:\apache\maven3.2.1\repository\commons-codec\commons-codec\1.11\commons-codec-1.11.jar;F:\apache\maven3.2.1\repository\org\apache\httpcomponents\httpclient-cache\4.5.2\httpclient-cache-4.5.2.jar;D:\JetBrains\IntelliJ IDEA 2016.3.4\lib\idea_rt.jar" com.intellij.rt.execution.application.AppMain com.ps.uzkefu.util.Test1
Thread-0:0
Thread-0:1
Thread-0:2
Thread-0:3
Thread-0:4
Thread-0:5
Thread-0:6
Thread-0:7
Thread-0:8
Thread-0:9
Thread-1:0
Thread-1:1
Thread-1:2
Thread-1:3
Thread-1:4
Thread-1:5
Thread-1:6
Thread-1:7
Thread-1:8
Thread-1:9

Process finished with exit code 0

 

线程0 和线程1 按照先后顺序执行

 

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

非ban必选

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值