期货 future
来源:互联网 发布:手机改机型软件 编辑:程序博客网 时间:2024/06/10 08:44
package _future;
public class Host {
public Data Request(final int count, final char c)
{
System.out.println(" request(" + count + ", " + c + ") BEGIN");
final FutureData future = new FutureData();
new Thread()
{
public void run()
{
RealData realData = new RealData(count, c);
future.setRealData(realData);
}
}.start();
System.out.println(" request(" + count + ", " + c + ") END");
return future;
}
}
package _future;
public class FutureData implements Data {
private RealData realData = null;
private boolean ready = false;
public synchronized void setRealData(RealData realData)
{
if(ready)
return ;
this.realData = realData;
this.ready = true;
notify();
}
@Override
public synchronized String getContent() {
while(!ready)
{
try {
wait();
} catch (InterruptedException e) {
e.printStackTrace();
}
}
return realData.getContent();
}
}
package _future;
public class RealData implements Data {
private final String content;
public RealData(int count,char c)
{
System.out.println(" Making RealData ( "+count+", "+c+" ) Begin");
char[] buffer = new char[count];
for(int i=0;i<count;i++)
{
buffer[i] = c;
try {
Thread.sleep(100);
} catch (InterruptedException e) {
}
}
System.out.println(" making RealData(" + count + ", " + c + ") END");
this.content = new String(buffer);
}
@Override
public String getContent() {
return content;
}
}
- 期货 future
- 股指期货(Stock Index Future)
- 期货
- 期货
- 期货
- 期货
- Future
- future
- future
- Future
- Future
- [future]
- Future
- Future
- future
- Future
- future
- 什么是期货
- 转:Keil MDK编译器与J-LINK使用
- 读写锁
- JQuery+JQuery ui实现的弹出窗口+遮罩层+拖动+更改大小~!
- asp.net中常用的技术(转)
- IIS安装说明
- 期货 future
- Android UI 事件研究
- apache 启动httpd.exe 报错 Could not reliably determine the server's fully qualified
- dvi转vga是无损的
- 网络驱动
- 区间树
- java复习
- 网络驱动
- SAP Duet的前世今生