public class Server extends Thread { Client client int counter public Server(Cli...
- 资源大小:1.08 kB
- 上传时间:2021-06-30
- 下载次数:0次
- 浏览次数:1次
- 资源积分:1积分
-
标 签:
Static
control
vb
资 源 简 介
public class Server extends Thread { Client client int counter public Server(Client _client) { this.client = _client this.counter = 0 } public void run() { while (counter < 10) { this.client.queue.addElement(new Integer(counter)) counter++ } throw new RuntimeException("counter >= 10") } public static void main(String[] args) { Client c = new Client() Server s = new Server(c) c.start() s.start() } } class Client extends Thread { Vector queue public Client() { this.queue = new Vector() } public void run() { while (true) { if (! (queue.size() == 0)) { processNextElement() } } } private void processNextElement() { Object next = queue.elementAt(0) queue.removeElementAt(0) System.out.println(next)-public class Server extends Thread { Client client int counter public Server(Client _client) { this.client = _client this.counter = 0 } public void run() { while (counter lt; 10) { this.client.queue.addElement(new Integer(counter)) counter++ } throw new RuntimeException("counter gt;= 10") } p