美文网首页
多线程创建

多线程创建

作者: 男青年的笔记 | 来源:发表于2019-11-01 09:34 被阅读0次

public class sellticket多线程创建 {
public static void main(String[] args) {
//第一种多线程创建方式
// thred thred = new thred ();
// thred.start ();

    //第二种多线程创建方式
    runnableimpl1 run1 = new runnableimpl1();
    Thread t0 = new Thread(run1);
    Thread t1 = new Thread(run1);
    Thread t2 = new Thread(run1);
    t0.start();
    t1.start();
    t2.start();


    //第三种多线程创建方式

// runnableimpl1 run1 = new runnableimpl1 ();
// while (true) {
// new Thread (run1).start ();

// }
//第四种匿名,借口是runnable直接重写
// Runnable rewrite = new Runnable () {
// @Override
// public void run() {
// System.out.println ("重写方法");
// }
// };
// new Thread (rewrite).start ();

// 第五种将rewrite也匿名
new Thread (new Runnable () {
@Override
public void run() {
System.out.println ("重写方法");
}
}).start ();

}

}

相关文章

  • 多线程

    创建一个多线程 创建多线程-继承线程类 创建多线程-实现Runnable接口 创建多线程-匿名类code

  • iOS基础知识 (三)

    多线程 多线程创建方式 iOS创建多线程方式主要有NSThread、NSOperation、GCD,这三种方式创建...

  • Python 多线程笔记

    Python 多线程笔记 创建线程 1. 使用函数创建多线程 2. 使用类创建多线程 继承 Thread 类 重写...

  • 10.3多线程详解

    Java高级-多线程 多线程创建 多线程通讯 线程池 1.多线程创建 thread/runnable图:继承Thr...

  • 多线程 -- threading

    多线程模块 threading 创建多线程的两种方式:import threadingimport time 创建...

  • JAVA基础—创建线程的3种方式

    线程的生命周期(五种状态) 创建线程的三种方式对比 1. 创建多线程-继承Thread 运行结果 2. 创建多线程...

  • 创建多少个线程才合适(一)?

    在创建线程之前我们需要考虑几个问题 1.创建多线程的目的是什么? 2.创建多线程的场景有哪些? 3.创建多个线程合...

  • 多线程的同步和异步

    多线程的同步和异步 1.创建多线程的方式 有两种方式创建多线程,一种是继承Thread类,一种是实现Runnabl...

  • NSOperation

    iOS多线程--彻底学会多线程之『NSOperation』 一. 基本用法 如果不创建BlockOperation...

  • android 多线程学习2:线程的创建与方法分析

    android 多线程学习1:一些基础android 多线程学习2:线程的创建与方法分析android 多线程学习...

网友评论

      本文标题:多线程创建

      本文链接:https://www.haomeiwen.com/subject/pmxfbctx.html