Site Search :
Standard Enterprise XML Methodology Pattern Setting Tunning Other
Article Contributors
GuestBook
Javapattern Maven
XSourceGen Dev
JetSpeed Test
JLook Image
jLook Family Site


Multiprocess JVM Implemetation
 
Java¸¦ ÀÌ¿ëÇØ ServerApplicationÀ» ±¸ÇöÇÒ ¶§ ±âº»ÀÌ µÉ ¼ö ÀÖ´Â Multiprocess JVMÀ» ±¸ÇöÇϱâ À§ÇÑ ±âº» Áö½ÄÀ» ½ÀµæÇغ¸°íÀÚ ÇÕ´Ï´Ù. ÀÌÁ¦ ¿ì¸®´Â ÇϳªÀÇ JVM¿¡¼­ ´Ù¼öÀÇ Process¸¦ »ý¼ºÇÏ°í °ü¸®ÇÒ ¼ö ÀÖ°Ô µË´Ï´Ù. ( 2003/02/28 ) 155
Written by runjava - ±èÀçȯ
2 of 2
 

4) MainThread°¡ Á¾·áµÉ ¶§´Â ±×¿¡ Æ÷ÇÔµÈ ChildThreadµéµµ ÇÔ²² Á¾·á½ÃÄÑ¾ß ÇÕ´Ï´Ù.

ÀÚ¹Ù´Â ¾ð¾îÂ÷¿ø¿¡¼­ MultiThread¸¦ Áö¿øÇÏ°í ÀÖ½À´Ï´Ù. ¸¸¾à »ý¼ºÇÑ ¾î¶² ÇÁ·Î¼¼½º ³»ºÎ¿¡¼­ ChildThread µéÀ» »ý¼ºÇÏ¿© ½ÇÇà½ÃŲ´ÙÀ½ MainThread¸¦ Á¾·á½ÃÅ°¸é ¾î¶² ÀÏÀÌ ¹ß»ýÇÒ±î¿ä? MainThread°¡ Á¾·áµÇ´õ¶óµµ ³ª¸ÓÁö ChildThreadµéÀº ¿©ÀüÈ÷ ÀÚ±â ÇÒ ÀÏÀ» ÇÏ°Ô µË´Ï´Ù.

ÀÌ°ÍÀ» ÇØ°áÇÏ·Á¸é ThreadGroup¸¦ ÀÌ¿ëÇÒ ¼ö ÀÖ½À´Ï´Ù. ThreadGroupÀº ThreadµéÀ» ÇϳªÀÇ GroupÀ¸·Î ¹­¾î µ¿½ÃÁ¦¾î¸¦ ÇÒ ¼ö ÀÖµµ·Ï µµ¿ÍÁÝ´Ï´Ù. ±×¸®°í, Á¾·á½Ã¿¡ ThreadGroup¿¡¼­ stop()À» È£ÃâÇÏ¸é ¿©±â¿¡ µî·ÏµÈ ¸ðµç ThreadµéÀ» µ¿½Ã¿¡ Á¾·á½Ãų ¼ö ÀÖ½À´Ï´Ù. À§¿¡¼­ º¸½Å ¼Ò½º¸¦ ¼öÁ¤ÇÒ ÇÊ¿ä°¡ »ý±é´Ï´Ù.
¼öÁ¤µÈ ³»¿ëÀº ProcessManager#startAnotherClass()¸¦ ÂüÁ¶Çϼ¼¿ä.

 

5) System.exit()¸¦ È£ÃâÇϸé ÇØ´ç ÇÁ·Î¼¼½º¸¸À» Á¾·áÇÏ°í JVMÀÌ Á¾·áµÇ´Â °ÍÀ» ¹æÁöÇØ¾ß ÇÕ´Ï´Ù.

±×·¸´Ù¸é, ´©±º°¡ ÇÁ·Î¼¼½º¸¦ Á¾·áÇϱâ À§ÇØ °£´ÜÇÏ°Ô System.exit()¸¦ ÀÌ¿ëÇß´Ù¸é ¾î¶² ÀÏÀÌ ¹ú¾îÁú±î¿ä? ¾Æ¸¶µµ JVMÀÌ Á¾·áµÊ°ú µ¿½Ã¿¡ ¿øÇÏÁö ¾Ê´ø ÀÏÀÌ ¹ß»ýÇÏ°ÚÁÒ? ¸ðµç ÇÁ·Î¼¼½º°¡ Á¾·áµÇ¾î ¹ö¸³´Ï´Ù. ÀÌ ¹®Á¦µµ ÇØ°áÀ» ÇØ¾ß ÇÒ °Í °°±º¿ä. Ȥ½Ã ÀÖÀ»Áöµµ ¸ð¸£´Â ºÒ»ó»ç¿¡ ´ëºñÇؾ߰ÚÁÒ?

java.lang.SecurityManager¸¦ »ó¼Ó¹Þ´Â »ç¿ëÀÚ Á¤ÀÇÀÇ SecurityManager¸¦ ÀÌ¿ëÇؼ­ ÇØ°áÇÕ´Ï´Ù. ProcessManger¿¡ ÀÌ SecurityManager¸¦ µî·ÏÇÏ¸é ´©±º°¡ System.exit()¸¦ È£ÃâÇÒ ¶§ checkExit() °¡ È£ÃâµÉ °ÍÀÔ´Ï´Ù. checkExit()¿¡¼­´Â System.exit()¸¦ È£ÃâÇÑ ÇÁ·Î¼¼½º¸¦ Á¾·á½ÃÅ°°í´Â ExceptionÀ» ¹ß»ý½ÃÄÑ ´ÙÀ½ÀÇ Á¾·áÀÛ¾÷À» ÁßÁö½ÃÅ°´Â ¹æ¹ýÀ¸·Î 󸮸¦ Çß½À´Ï´Ù. ÄÚµå´Â ExitCatchingSecruityManger.java¸¦ ÂüÁ¶Çϼ¼¿ä.

¾ÆÁ÷ Áß¿äÇÑ ÇÑ°¡Áö ¹®Á¦°¡ ³²¾ÆÀÖ½À´Ï´Ù.
Multiprocess JVMÀº ÁÖ·Î ¼­¹ö ¾ÖÇø®ÄÉÀ̼ÇÀ» Á¦ÀÛÇÒ ¶§ ±¸ÇöµË´Ï´Ù. ±×·¸´Ù¸é ¿©·¯ ÇÁ·Î¼¼½ºµéÀÌ ¸ðµÎ ¶È°°Àº Library¸¦ »ç¿ëÇؼ­ ÀÛµ¿ÇÏÁö´Â ¾Ê°ÚÁÒ? Áï, °¢°¢ÀÇ ÇÁ·Î¼¼½º¸¶´Ù classpathµîÀÇ È¯°æÁ¤º¸¸¦ ´Ù¸£°Ô Àû¿ëÇÒ ¼ö ÀÖ¾î¾ß ÇÑ´Ù´Â ¾ê±âÀÔ´Ï´Ù.
ÀÌ ¹®Á¦´Â ¶Ç ¾îÂî ÇØ°áÇÒ °ÍÀΰ¡? ÀÏ´Ü URLClassLoader¸¦ È®ÀåÇؼ­ ÇØ°áÇÒ ¼ö ÀÖ´Ù´Â ÈùÆ®¸¸ µå¸®±¸¿ä. ÀÚ¼¼ÇÑ ¼Ò½º¿Í Çؼ³Àº ´ÙÀ½ Multiprocess JVM(2)¿¡¼­ °è¼Ó À̾îÁý´Ï´Ù.

 

3. ¿¹Á¦ ÇÁ·Î±×·¥ ½ÇÇà¹æ¹ý
  1) ³»·Á¹ÞÀº ÆÄÀÏÀ» µð·ºÅ丮¿¡ ¾ÐÃàÀ» DZ´Ï´Ù.
  2) bin/test.bat ÆÄÀÏÀ» ½ÇÇà½ÃÅ°½Ã¸é µË´Ï´Ù.
  3) ¼Ò½º´Â /src ¿¡ ÀÖ½À´Ï´Ù.

SampleApp.java , SampleApp2.java, MultiprocessTest.java ´Â ½ÇÇà¸ð½ÀÀ» º¸±âÀ§ÇÑ »ùÇÃÇÁ·Î±×·¥ÀÔ´Ï´Ù. MultiprocessTestÀÇ main()¿¡¼­ SampleApp¿Í SampleApp2¸¦ ½ÇÇà½ÃÅ°µµ·Ï µÇ¾î ÀÖ½À´Ï´Ù.

4. ¿¹Á¦ ÇÁ·Î±×·¥ ¼³¸í
  MultiprocessTest¿¡¼­ 3°³ÀÇ Process ¸¦ »ý¼ºÇÕ´Ï´Ù.
  Process1 : ¿©·¯°³ÀÇ ChildThread¸¦ »ý¼ºÇÏ°í MainThread°¡ Á¾·áµÉ ¶§ ChildThreadµéÀÌ µ¿½Ã¿¡ Á¾·áµÇ´Â °ÍÀ» º¸¿©ÁÝ´Ï´Ù.
  Process2 : Process ³»ºÎ¿¡¼­ System.exit()°¡ È£ÃâµÉ ¶§ ÀÚ±â ÀڽŸ¸À» Á¾·á½ÃÅ°°í ³ª¸ÓÁö Processµé¿¡°Ô ¿µÇâÀ» ³¢Ä¡Áö ¾Ê´Â´Ù´Â °ÍÀ» º¸¿©ÁÝ´Ï´Ù.
  Process3 : ³¡±îÁö ½ÇÇàÀ» ¸¶Ä¡°í Á¾·áÇÕ´Ï´Ù.

 

À¯ÀÍÇÑ ÀÚ·á°¡ µÇ½Ã±æ ¹Ù¶ø´Ï´Ù.

 
1 2
References
 
1) O'REILY NETWORK : Multiprocess JVMs 2001/09/25
2) The Java Language Specification : Chapter 17 Threads and Locks 3) This article Source : jvm_process_src.zip
Copyright ¨Ï 2003 www.javapattern.info & www.jlook.com, an jLOOK co.,LTD