zoukankan      html  css  js  c++  java
  • JAVA日报

    JAVA多线程

    class RunnableDemo implements Runnable {

    private Thread t;

    private String threadName;

    RunnableDemo( String name) { threadName = name;

    System.out.println("Creating " + threadName ); }

    public void run() { System.out.println("Running " + threadName );

    try { for(int i = 4; i > 0; i--) { System.out.println("Thread: " + threadName + ", " + i); // 让线程睡眠一会

    Thread.sleep(50); } }catch (InterruptedException e) { System.out.println("Thread " + threadName + " interrupted."); }

    System.out.println("Thread " + threadName + " exiting."); } public void start () { System.out.println("Starting " + threadName );

    if (t == null) { t = new Thread (this, threadName);

    t.start (); } } } public class TestThread { public static void main(String args[]) { RunnableDemo R1 = new RunnableDemo( "Thread-1"); R1.start(); RunnableDemo R2 = new RunnableDemo( "Thread-2"); R2.start(); } }

  • 相关阅读:
    Post返回json值
    调用接口并获取放回json值
    c# 获取IP
    sqlserver2008不允许保存更改
    判断客户端是否是手机或者PC
    3.docker tomcat集群
    1.docker 安装
    Maven profiles 多环境配置
    MySQL 定时任务
    MyBatis 三剑客
  • 原文地址:https://www.cnblogs.com/mumulailai/p/14158574.html
Copyright © 2011-2022 走看看