Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

How Java handles arguments of a class type.

=====suppose such a method:
public static void openFile(String fileName, PrintWriter stream) throws FileNotFoundException
{
   stream = new PrintWriter(fileName);
}
=====then we want to use it this way:
PrintWriter toFile = null;
try
{
   openFile("data.txt", toFile);
}
*****After this code is executed, the value of toFile is still null. The file that was opened in the method openFile went away when the method ended. The problem has to do with how Java handles arguments of a class type.
"These arguments are passed to the method as memory addresses that cannot be changed. The state of the object at the memory address normally can be changed, but the memory address itself cannot be changed"!


Ïà¹ØÎĵµ£º

JavaÍøÕ¾1

http://www.onjava.com
    O'ReillyµÄJavaÍøÕ¾. ÿÖܶ¼ÓÐÐÂÎÄÕÂ
http://java.sun.com
    ¹Ù·½µÄJava¿ª·¢ÕßÍøÕ¾ - ÿÖܶ¼ÓÐÐÂÎÄÕ·¢±í
http://www.developer.com/java
    ÓÉGamelan.com ά»¤µÄJava¼¼ÊõÎÄÕÂÍøÕ¾
http://www.java.net
  &nb ......

ÓйØjavaÖеÄÒýÓÃÎÊÌâ

Ê×ÏÈ£¬java¶Ô¶ÔÏóºÍ»ù±¾ÀàÐ͵Ĵ¦ÀíÊDz»Ò»ÑùµÄ£¬ºÍCÓïÑÔÒ»Ñù£¬µ±°ÑJavaµÄ»ù±¾Êý¾ÝÀàÐÍ£¨Èçint£¬char£¬doubleµÈ£©×÷ΪÈë¿Ú²ÎÊý´«¸øº¯ÊýÌåµÄʱºò£¬´«ÈëµÄ²ÎÊýÔÚº¯ÊýÌåÄÚ²¿±ä³ÉÁ˾ֲ¿±äÁ¿£¬Õâ¸ö¾Ö²¿±äÁ¿ÊÇÊäÈë²ÎÊýµÄÒ»¸ö¿½±´£¬ËùÓеĺ¯ÊýÌåÄÚ²¿µÄ²Ù×÷¶¼ÊÇÕë¶ÔÕâ¸ö¿½±´µÄ²Ù×÷£¬º¯ÊýÖ´ÐнáÊøºó£¬Õâ¸ö¾Ö²¿±äÁ¿Ò²¾ÍÍê³ÉÁËËüµÄʹÃü£¬ ......

Java¶àÏ̱߳à³Ì»·¾³Öе¥ÀýģʽµÄʵÏÖ

Abstract
        
ÔÚ¿ª·¢ÖУ¬Èç¹ûij¸öʵÀýµÄ´´½¨ÐèÒªÏûºÄºÜ¶àϵͳ×ÊÔ´£¬ÄÇôÎÒÃÇͨ³£»áʹÓöèÐÔ¼ÓÔØ»úÖÆ£¬Ò²¾ÍÊÇ˵ֻÓе±Ê¹Óõ½Õâ¸öʵÀýµÄʱºò²Å»á´´½¨Õâ¸öʵÀý£¬Õâ¸öºÃ´¦ÔÚ
µ¥ÀýģʽÖеõ½Á˹㷺ӦÓá£Õâ¸ö»úÖÆÔÚsingle-threaded»·¾³ÏµÄʵÏַdz£¼òµ¥£¬È»¶øÔÚmulti-threaded» ......

Java Semaphore

package test;
/**
*
* @author openpk
*/
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Semaphore;
public class Main {
public static void main(String[] args) {
// Ï̳߳Ø
ExecutorService exec = Executors ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ