תÌù×Ô http://www.3800hk.com/Article/cxsj/java/jcjcjave/2009-11-10/Article_181759.html
¡¡1. Õ»(stack)Óë¶Ñ(heap)¶¼ÊÇJavaÓÃÀ´ÔÚRamÖдæ·ÅÊý¾Ý
µÄµØ·½¡£ÓëC++²»Í¬£¬Java×Ô¶¯
ÖÎÀíÕ»ºÍ¶Ñ£¬³ÌÐòÔ±²»ÄÜÖ±½ÓµØÉèÖÃÕ»»ò¶Ñ¡£
¡¡¡¡
¡¡¡¡2. Õ»µÄÓÅÊÆÊÇ£¬´æÈ¡ËٶȱȶÑÒª¿ì£¬½ö´ÎÓÚÖ±½ÓλÓÚCPUÖеļĴæÆ÷¡£µ«È±µãÊÇ£¬´æÔÚÕ»ÖеÄÊý¾Ý´óСÓëÉú´æÆÚ±ØÐëÊÇÈ·¶¨µÄ£¬È±·¦Áé»îÐÔ¡£ÁíÍ⣬ջÊý¾Ý
¿ÉÒÔ¹²Ïí£¬Ïê¼ûµÚ3µã¡£¶ÑµÄÓÅÊÆÊÇ¿ÉÒÔ¶¯Ì¬µØ·ÖÅäÄÚ´æ´óС£¬Éú´æÆÚÒ²²»±ØÊÂÏȸæËß±àÒëÆ÷£¬JavaµÄÀ¬»øÊÕ¼¯Æ÷»á×Ô¶¯
ÊÕ×ßÕâЩ²»ÔÙʹÓõÄÊý¾Ý
¡£µ«È±µãÊÇ£¬ÓÉÓÚÒªÔÚÔËÐÐʱ¶¯Ì¬·ÖÅäÄڴ棬´æÈ¡ËٶȽÏÂý¡£
¡¡¡¡
¡¡¡¡3. JavaÖеÄÊý¾Ý
ÀàÐÍÓÐÁ½ÖÖ¡£
¡¡¡¡
¡¡
¡¡Ò»ÖÖÊÇ»ù±¾ÀàÐÍ(primitive types), ¹²ÓÐ8ÖÖ£¬¼´int, short, long, byte, float, double,
boolean, char(×¢ÖØ£¬²¢Ã»ÓÐstringµÄ»ù±¾ÀàÐÍ)¡£ÕâÖÖÀàÐ͵͍ÒåÊÇͨ¹ýÖîÈçint a = 3; long b =
255L;µÄÐÎʽÀ´¶¨ÒåµÄ£¬³ÆÎª×Ô¶¯±äÁ¿¡£ÖµµÃ×¢ÖØµÄÊÇ£¬×Ô¶¯
±äÁ¿´æµÄÊÇ×ÖÃæÖµ£¬²»ÊÇÀàµÄʵÀý£¬¼´²»ÊÇÀàµÄÒýÓã¬ÕâÀﲢûÓÐÀàµÄ´æÔÚ¡£Èçint a = 3; ÕâÀïµÄaÊÇÒ»¸öÖ¸ÏòintÀàÐ͵ÄÒýÓã¬Ö¸Ïò3Õâ¸ö×ÖÃæÖµ¡£ÕâЩ×ÖÃæÖµµÄÊý¾Ý
£¬ÓÉÓÚ´óС¿ÉÖª£¬É ......
javaµ÷ÓÃÍⲿ³ÌÐò ±ØÉ± ·¾¶¿Õ¸ñûÓÐÎÊÌâ
Runtime rt = Runtime.getRuntime();
srcFile.getName();
try {
String cmd[]={"cmd","/c",srcFile.getAbsolutePath()};
rt.exec(cmd);
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
......
TBCPMessageFactory.java
/**
* ÎļþÃû: TBCPMessageFactory.java
*/
package tbcpstack;
import java.text.MessageFormat;
import org.apache.log4j.Logger;
import TBCPException;
/**
*
* TODO TBCPÏûÏ¢¹¹½¨¹¤³§
*/
public class TBCPMessageFactory {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(TBCPMessageFactory.class);
private static final String POCNAME = "PoC1";
/**
* °´ÕÕOMA PoC UserPlaneÀï¹æ¶¨µÄTBCP Talk Burst RequestÏûÏ¢¸ñʽ½øÐй¹Ôì¡£
*
* @param ssrc
* SSRC of PoC Client requesting permission to send a talk burst
* @param priority
* Ö»ÄÜΪ1¡¢2¡¢3¡£ 1 - normal priority£»2 - high priority£»3 -
* pre-emptivepriority
* @return bytes of TalkBurstRequest
* @throws TBCPException
*/
public static byte[] createTBCPTalkBurstRequest(long ssrc, int priority) throws TBCPException {
if ((1 <= priority) & ......
Ò» Ï̵߳Ļù±¾¸ÅÄî
Ïß³ÌÊÇÒ»¸ö³ÌÐòÄÚ²¿µÄ˳Ðò¿ØÖÆÁ÷.Ò»¸ö½ø³ÌÏ൱ÓÚÒ»¸öÈÎÎñ,Ò»¸öÏß³ÌÏ൱ÓÚÒ»¸öÈÎÎñÖеÄÒ»ÌõÖ´Ðз¾¶.£»¶à½ø³Ì:ÔÚ²Ù×÷ϵͳÖÐÄÜͬʱÔËÐжà¸öÈÎÎñ (³ÌÐò)£»¶àÏß³Ì:ÔÚͬһ¸öÓ¦ÓóÌÐòÖÐÓжà¸ö˳ÐòÁ÷ͬʱִÐУ»JavaµÄÏß³ÌÊÇͨ¹ýjava.lang.ThreadÀàÀ´ÊµÏֵģ»JVMÆô¶¯Ê±»áÓÐÒ»¸öÓÉÖ÷·½·¨(public static void main(){})Ëù¶¨ÒåµÄỊ̈߳»¿ÉÒÔͨ¹ý´´½¨ThreadµÄʵÀýÀ´´´½¨ÐµÄỊ̈߳»Ã¿¸öÏ̶߳¼ÊÇͨ¹ýij¸öÌØ¶¨Thread¶ÔÏóËù¶ÔÓ¦µÄ·½·¨run()À´Íê³ÉÆä²Ù×÷µÄ,·½·¨run()³ÆÎªÏß³ÌÌ壬ͨ¹ýµ÷ÓÃThreadÀàµÄstart()·½·¨À´Æô¶¯Ò»¸öÏ̡߳£
¶þ Ï̵߳Ĵ´½¨ºÍÆô¶¯
¿ÉÒÔÓÐÁ½ÖÖ·½Ê½´´½¨ÐµÄÏß³Ì:
µÚÒ»ÖÖ:
1.¶¨ÒåÏß³ÌÀàʵÏÖRunnable½Ó¿Ú
2.Thread myThread = new Thread(target); //targetΪRunnable½Ó¿ÚÀàÐÍ
3.RunnableÖÐÖ»ÓÐÒ»¸ö·½·¨:public void run();ÓÃÒÔ¶¨ÒåÏß³ÌÔËÐÐÌå
4.ʹÓÃRunnable½Ó¿Ú¿ÉÒÔΪ¶à¸öÏß³ÌÌṩ¹²ÏíµÄÊý¾Ý
5.ÔÚʵÏÖRunnable½Ó¿ÚµÄÀàµÄrun()·½·¨¶¨ÒåÖпÉÒÔʹÓÃThreadµÄ¾²Ì¬·½·¨public static Thread currentThread();»ñÈ¡µ±Ç°Ï̵߳ÄÒýÓÃ
µÚ¶þÖÖ:
1.¿ÉÒÔ¶¨ÒåÒ»¸öThreadµÄ×ÓÀà²¢ÖØÐ´Æärun·½·¨Èç:
class MyThread extends Thread { ......
²»ÌᳫʹÓõķ½·¨ÊÇΪ֧³ÖÏòºó¼æÈÝÐÔ¶ø±£ÁôµÄÄÇЩ·½·¨£¬ËüÃÇÔÚÒÔºóµÄ°æ±¾ÖпÉÄܳöÏÖ£¬Ò²¿ÉÄܲ»³öÏÖ¡£Java ¶àÏß³ÌÖ§³ÖÔÚ°æ±¾ 1.1 ºÍ°æ±¾ 1.2 ÖÐ×öÁËÖØ´óÐÞ¶©£¬stop()¡¢suspend() ºÍ resume() º¯ÊýÒѲ»ÌᳫʹÓá£ÕâЩº¯ÊýÔÚ JVM ÖпÉÄÜÒýÈë΢ÃîµÄ´íÎó¡£ËäÈ»º¯ÊýÃû¿ÉÄÜÌýÆðÀ´ºÜÓÕÈË£¬µ«ÇëµÖÖÆÓÕ»ó²»ÒªÊ¹ÓÃËüÃÇ¡£
µ÷ÊÔÏ̻߳¯µÄ³ÌÐò
ÔÚJavaÏ̻߳¯µÄ³ÌÐòÖУ¬¿ÉÄÜ·¢ÉúµÄijЩ³£¼û¶øÌÖÑáµÄÇé¿öÊÇËÀËø¡¢»îËø¡¢ÄÚ´æË𻵺Í×ÊÔ´ºÄ¾¡¡£
ËÀËø
ËÀËø¿ÉÄÜÊÇJava¶àÏ̳߳ÌÐò×î³£¼ûµÄÎÊÌâ¡£µ±Ò»¸öÏß³ÌÐèÒªÒ»¸ö×ÊÔ´¶øÁíÒ»¸öÏ̳߳ÖÓиÃ×ÊÔ´µÄËøÊ±£¬¾Í»á·¢ÉúËÀËø¡£ÕâÖÖÇé¿öͨ³£ºÜÄѼì²â¡£µ«ÊÇ£¬½â¾ö·½°¸È´Ï൱ºÃ£ºÔÚËùÓеÄÏß³ÌÖа´ÏàͬµÄ´ÎÐò»ñÈ¡ËùÓÐ×ÊÔ´Ëø¡£ÀýÈ磬Èç¹ûÓÐËĸö×ÊÔ´ —A¡¢B¡¢C ºÍ D — ²¢ÇÒÒ»¸öÏ߳̿ÉÄÜÒª»ñÈ¡Ëĸö×ÊÔ´ÖÐÈκÎÒ»¸ö×ÊÔ´µÄËø£¬ÔòÇëÈ·±£ÔÚ»ñÈ¡¶Ô B µÄËøÖ®Ç°Ê×ÏÈ»ñÈ¡¶Ô A µÄËø£¬ÒÀ´ËÀàÍÆ¡£Èç¹û“Ïß³Ì 1”Ï£Íû»ñÈ¡¶Ô B ºÍ C µÄËø£¬¶ø“Ïß³Ì 2”»ñÈ¡ÁË A¡¢C ºÍ D µÄËø£¬ÔòÕâÒ»¼¼Êõ¿ÉÄܵ¼ÖÂ×èÈû£¬µ«ËüÓÀÔ¶²»»áÔÚÕâËĸöËøÉÏÔì³ÉËÀËø¡£
»îËø
µ±Ò»¸öÏß³ÌæÓÚ½ÓÊÜÐÂÈÎÎñÒÔÖÂËüÓÀԶûÓлú»áÍê³ÉÈκÎÈÎÎñʱ£¬¾Í»á·¢Éú»îËø¡£Õâ¸öÏß³Ì×îÖÕ½«³¬³ö»º³å ......
Ò»£ºÀí½âJava¶àÏß³Ì
¶àÏß³ÌÊÇÕâÑùÒ»ÖÖ»úÖÆ£¬ËüÔÊÐíÔÚ³ÌÐòÖв¢·¢Ö´Ðжà¸öÖ¸ÁîÁ÷£¬Ã¿¸öÖ¸ÁîÁ÷¶¼³ÆÎªÒ»¸öỊ̈߳¬±Ë´Ë¼ä»¥Ïà¶ÀÁ¢¡£Ïß³ÌÓÖ³ÆÎªÇáÁ¿¼¶½ø³Ì£¬ËüºÍ½ø³ÌÒ»ÑùÓµÓжÀÁ¢µÄÖ´ÐпØÖÆ£¬ÓɲÙ×÷ϵͳ¸ºÔðµ÷¶È£¬Çø±ðÔÚÓÚÏß³ÌûÓжÀÁ¢µÄ´æ´¢¿Õ¼ä£¬¶øÊǺÍËùÊô½ø³ÌÖÐµÄÆäËüÏ̹߳²ÏíÒ»¸ö´æ´¢¿Õ¼ä£¬ÕâʹµÃÏ̼߳äµÄͨÐÅÔ¶½Ï½ø³Ì¼òµ¥¡£
¶à¸öÏ̵߳ÄÖ´ÐÐÊDz¢·¢µÄ£¬Ò²¾ÍÊÇÔÚÂß¼Éϓͬʱ”£¬¶ø²»¹ÜÊÇ·ñÊÇÎïÀíÉϵēͬʱ”¡£Èç¹ûϵͳֻÓÐÒ»¸öCPU£¬ÄÇ̫;ÕýµÄ“ͬʱ”ÊDz»¿ÉÄܵ쬵«ÊÇÓÉÓÚCPUµÄËٶȷdz£¿ì£¬Óû§¸Ð¾õ²»µ½ÆäÖеÄÇø±ð£¬Òò´ËÎÒÃÇÒ²²»ÓùØÐÄËü£¬Ö»ÐèÒªÉèÏë¸÷¸öÏß³ÌÊÇͬʱִÐм´¿É¡£
¶àÏ̺߳ʹ«Í³µÄµ¥Ïß³ÌÔÚ³ÌÐòÉè¼ÆÉÏ×î´óµÄÇø±ðÔÚÓÚ£¬ÓÉÓÚ¸÷¸öÏ̵߳ĿØÖÆÁ÷±Ë´Ë¶ÀÁ¢£¬Ê¹µÃ¸÷¸öÏß³ÌÖ®¼äµÄ´úÂëÊÇÂÒÐòÖ´Ðеģ¬ÓÉ´Ë´øÀ´µÄÏ̵߳÷¶È£¬Í¬²½µÈÎÊÌ⣬½«ÔÚÒÔºó̽ÌÖ¡£
¶þ£ºÊµÏÖJava¶àÏß³Ì
ÎÒÃDz»·ÁÉèÏ룬ΪÁË´´½¨Ò»¸öеÄỊ̈߳¬ÎÒÃÇÐèÒª×öЩʲô£¿ºÜÏÔÈ»£¬ÎÒÃDZØÐëÖ¸Ã÷Õâ¸öÏß³ÌËùÒªÖ´ÐеĴúÂ룬¶øÕâ¾ÍÊÇÔÚJavaÖÐʵÏÖ¶àÏß³ÌÎÒÃÇËùÐèÒª×öµÄÒ»ÇУ¡
ÕæÊÇÉñÆæ£¡JavaÊÇÈçºÎ×öµ½ÕâÒ»µãµÄ£¿Í¨¹ýÀ࣡×÷Ϊһ¸öÍêÈ«ÃæÏò¶ÔÏóµÄÓïÑÔ£¬JavaÌṩÁËÀà java.lang.Thread À´·½ ......