helloworldclient.java
来自「JAVA分布式程序学习的课件(全英文)」· Java 代码 · 共 32 行
JAVA
32 行
// A client program which accesses a JavaSpaces entry.
// M. Liu, based on code samples provided in:
// JAVASPACES PRINCIPLES, PATTERNS, AND PRACTICE,
// Freeman, et al, Addison-Wesley Publishing Co
// (http://java.sun.com/docs/books/jini/javaspaces/)
import net.jini.core.lease.Lease;
import net.jini.space.JavaSpace;
public class HelloWorldClient {
public static void main(String[] args) {
try {
JavaSpace space = (JavaSpace)space();
SpaceObject template = new SpaceObject();
// Repeatedly retrieve the object from the space,
// update it, then deposit the object in the space
while (true) {
// Read the object from the space.
SpaceObject result = (SpaceObject)
space.take(template, null, Long.MAX_VALUE);
result.increment();
// Write the object to the space
space.write(result, null, Lease.FOREVER);
Thread.sleep(1000);
}//end while
}
catch (Exception ex) {
ex.printStackTrace();
}
}
} //end class
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?