chenyanlong

前言:多线程的知识

代码:

 1 package com.day13.math;
 2 /** 
 3 * 类说明 :模拟QQ聊天与视频聊天同时进行
 4 * @author 作者 : chenyanlong 
 5 * @version 创建时间:2017年10月29日 
 6 */
 7 
 8 public class ThreadTest {
 9 
10     public static void main(String[] args) {
11         TalkThread talkThread=new TalkThread();
12         VideoThread  videoThread=new VideoThread();
13         talkThread.start();
14         videoThread.start();
15     }
16 }
17 
18 
19 //发起视频
20 class TalkThread extends Thread{
21     
22     //重写run()方法
23     @Override
24     public void run(){
25         while(true){
26             System.out.println("霞霞,开视频呗!");
27         }
28     }
29 }
30 
31 
32 //视频
33 class VideoThread extends Thread{
34     //重写run方法
35     @Override
36     public void run(){
37         while(true){
38             System.out.println("好啊,那开视频呀!");
39         }
40     }
41 }
View Code

运行效果:

 

分类:

技术点:

相关文章:

  • 2021-09-18
  • 2021-11-19
  • 2021-11-22
  • 2021-09-24
  • 2021-10-18
  • 2021-12-20
  • 2021-04-06
猜你喜欢
  • 2021-06-13
  • 2021-11-14
  • 2021-04-25
  • 2021-09-01
  • 2022-01-04
  • 2022-01-21
  • 2021-09-29
相关资源
相似解决方案