3G体验手机展示程序 3G体验手机展示程序 3G体验手机展示程序

源代码在线查看: sender.java

软件大小: 7 K
上传用户: setixp
关键词: 3G体验 手机展 程序
下载地址: 免注册下载 普通下载 VIP

相关代码

				package com.hongguan.lifeshowclient2;
				
				import java.io.*; 
				
				public class Sender extends Thread { 
				
					private OutputStream os; 
					private String message; 
				
					public Sender(OutputStream os) { 
						this.os = os;
						start(); 
					} 
				
					public synchronized void send(String msg) {
						message = msg; 
						notify(); 
					} 
				
					public synchronized void run() { 
						while(true) { // If no client to deal, wait until one connects 
							if (message == null) { 
								try { 
									wait(); 
								} catch (InterruptedException e) { } 
							} if (message == null) { 
								break; } 
				
							try { 
								os.write(message.getBytes()); 
				//				os.write("\r\n".getBytes()); 
							} catch (IOException ioe) { 
								ioe.printStackTrace(); 
							} // Completed client handling, return handler to pool and 
						} 
					}
				
				/*	public final void stop() { 
						message = null;
						notify();
					} */
				}			

相关资源