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

📄 connectionclient.java

📁 the source code of voyager examples---connnection
💻 JAVA
字号:
// (c) Copyright 2003 Recursion Software, Inc.

package examples.connectionmgmt;

import com.recursionsw.ve.Namespace;
import com.recursionsw.ve.Voyager;
import com.recursionsw.ve.transport.Transport;

import examples.stockmarket.IStockmarket;

public class ConnectionClient implements Runnable {
    IStockmarket market;
    String announcement;

    public ConnectionClient(IStockmarket market, String str) {
        this.market = market;
        this.announcement = str;
    }

    public void run() {
        try {
            market.news(announcement);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        try {
            Voyager.startup();
            // obtain a proxy to the object on port 9000 with symbol "NASDAQ"
            Transport.addEventListener(new ConnectionListener());
            IStockmarket market =
                (IStockmarket) Namespace.lookup("9000/NASDAQ");
            // Create six connections.
            System.out.println("Calling server...");

            int threads = 6;
            Thread[] all = new Thread[threads];
            for (int idx = 0; idx < threads; idx++) {
                all[idx] = new Thread(new ConnectionClient(market, "Headline #" + (idx + 1)));
                all[idx].start();
            }
            for (int idx = 0; idx < threads; idx++) {
            	all[idx].join();
            }
            Voyager.shutdown();
        } catch (Exception exception) {
            exception.printStackTrace();
        }
    }
}

⌨️ 快捷键说明

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