Java NIO
Why NIO ?
http://onjava.com/pub/a/onjava/2002/09/04/nio.html?page=1
Java developers might ask: why introducing a new technology to handle sockets? What's wrong with the Java 1.3.x sockets? Suppose you would like to implement a server accepting diverse client connections. Suppose, as well, that you would like the server to be able to process multiple requests simultaneously. Using Java 1.3.x, you have two choices to develop such a server:
Implement a multithread server that manually handles a thread for each connection.
Using an external third-party module.
Both solutions work, but adopting the first one -- the whole thread-management solution, with related concurrency and conflict troubles -- has to be developed by programmer. The second solution may cost money, and it makes the application dependent on a non-JDK external module. By means of the nonblocking socket, you can implement a nonblocking server without directly managing threads or resorting to external modules.
In internal benchmarks, the router was able to handle up to 10,000 clients with no significant drop in throughput. For comparison, we implemented a version based on the thread-per-client model, which was only able to reach 3,000 clients, with a significant drop in throughput as the number of clients increased. (Thread Pool not alleviate it)
http://java.sun.com/j2se/1.4.2/docs/guide/nio/example/index.html
http://rox-xmlrpc.sourceforge.net/niotut/
Q: use loop to read or read assembling ?
/**
* several reads
*/
ByteBuffer buffer = ByteBuffer.allocate(10 * 1024);
...
int readBytes = sc.read(inBuffer);
buffer.put(inBuffer);
int target = 1024;
if(buffer.position() == 1024)
//get all the data, handle it
else
//hold buffer for next read
/**
* read in loop
*/
int target = 1024;
int totalRead = 0;
while(totalRead != 1024)
{
int readBytes = sc.read(intBuffer);
if(readBytes == -1)
break;
totalRead += readBytes;
}
//get all the data, handle it
相关文档:
import java.text.*;
import java.util.*;
/**
*
* <p>
* Title: 通用工具类
* </p>
* <p>
* Description: 常用工具的集合,用来处理常见问题,比如中文乱码的方法等。
* </p>
* <p>
* Copyright: Copyright (c) 2003
* </p>
* <p>
* Company: Towery
* </ ......
计算机缓存的定义 :缓存是CPU的一部分,它存在于CPU中
就此可以说明 CPU中不可能存放大量的数据
所以java 的缓存 不是真正意义上的缓存
而且
缓存是为了解决CPU速度和内存速度的速度差异问题
内存中被CPU访问最频繁的数据和指令被复制入CPU中的缓存,这样CPU就可以不经常到象“蜗牛”一样慢的内存中去取数 ......
char在java中称为“字符型” 占2个字节
字符常量是用单引号括起的一个字符 且字符常量在内存中存储的是该字符在Unicode字符集中的排序位置,即整数
eg:char x='a'
内存x中存储的是字符a在Unicode字符集中的排序位置97 因此允许将上面的语句写成char x=97;
由此例可以得出以下结论:
1.要 ......
Oracle and Sun
http://www.oracle.com/events/productstrategy/index.html
Oracle + Sun: Java Strategy
http://oracle.com.edgesuite.net/ivt/4000/8104/9236/12630/lobby_external_flash_clean_480x360/default.htm
Oracle + Sun: Java Strategy
......
将Flex与Spring集成后(BlazeDS 与Spring集成指南 ),第一个面临的问题就是:对于Java端返回的各种Java类型的对象,Flex中能否有相应的数据类型来映射。
处理,尤其是List、Set、Map及POJO对象值。
在 BlazeDS 与Spring集成指南 例子的基础上,调整相关的测试代码如下:
1、Java端
1.1、com.yeeach.HelloWorldService ......