实现Runnable接口
package com.LearnJava.Thread; class myRunnable implements Runnable{ @Override public void run() { for(int i =0;i<100;i++){ if(i%2==0){ System.out.println(i); } } } } public class threadTest2 { public static void main(String[] args) { myRunnable m = new myRunnable(); Thread t = new Thread(m); t.start(); } }
原文:https://www.cnblogs.com/superxuezhazha/p/12269993.html