Thread常用方法
Java--测试Thread中的常用方法

注意一下这个方法sleep(millitime)

直接调用sleep方法会报错,因为本身抛了一个异常,我们需要处理。此处不能通过throws抛异常,因为必须在run()方法下throws,但是run是重写的thread类的run()方法,原方法并没有throws。
Java--测试Thread中的常用方法
Java--测试Thread中的常用方法

所以此方法只能try-catch 而不能使用throws

Java--测试Thread中的常用方法

Java--测试Thread中的常用方法

其他方法

Java--测试Thread中的常用方法

相关文章:

  • 2021-11-27
  • 2021-10-25
  • 2021-08-18
  • 2021-12-16
  • 2022-02-07
猜你喜欢
  • 2020-04-28
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
  • 2021-10-17
  • 2022-12-23
相关资源
相似解决方案