⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sender.java

📁 一个midlet应用模型 非常经典的例子 大家可以看看 非常经典
💻 JAVA
字号:
/* * @(#)Sender.java	1.4 03/03/02 * * Copyright (c) 2004 Sun Microsystems, Inc.  All rights reserved. * Use is subject to license terms */package example.socket;import java.io.OutputStream;import java.io.IOException;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            // mark for wait            message = null;        }    }    public synchronized void stop() {        message = null;        notify();    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -