摘要: 1.start():启动当前线程,调用当前线程的run() 2.run():通常需要重写Tread类中的此方法,将创建的线程要执行的操作声明 在此方法中 3. currentThread():静态方法,返回执行当前代码的线程 4.getName():获取当前线程的名字 5.setName():设置当 阅读全文
posted @ 2022-08-10 22:29 Mr_sven 阅读(64) 评论(0) 推荐(0) 编辑
摘要: 方式一:1.创建一个继承Thread类的子类2.重写Thread类的run()3.创建Thread类的子类的对象4.通过此对象调用start() public class ThreadTest { public static void main(String[] args) { MyThread t 阅读全文
posted @ 2022-08-10 21:43 Mr_sven 阅读(19) 评论(0) 推荐(0) 编辑