1.继承Thread类创建线程 package com.practise.createthread; public class AnonymousThread { public static void main(String[] args) { new Thread("线程一") { public void run() { for(int i=1;i<=20;i++) { System.out.println(Thread.currentThread().getName()…
1.实现Runnable接口,重载run(),无返回值 package thread; public class ThreadRunnable implements Runnable { public void run() { for (int i = 0; i < 10; i++) { System.out.println(Thread.currentThread().getName() + ":" + i); } } } package thread; public clas…