模擬QQ聊天與視頻聊天同時進行-------java基礎知識總結
阿新 • • 發佈:2017-10-29
span img mage java基礎知識 java基礎 @override args pub spa
前言:多線程的知識
代碼:
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=newView CodeVideoThread(); 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 }
運行效果:
模擬QQ聊天與視頻聊天同時進行-------java基礎知識總結