::: Zany's Homepage ::: Zany Wiki | »çÀÌÆ® ÅëÇÕ °Ë»ö
 
 
 

[spring] Schedule fixedRate vs fixedDelay

°Ô½ÃÆÇ
JAVA
ÀÛ¼ºÀÚ
helix
ÀÛ¼ºÀÏ
2019-07-03 16:50:25
ÀÐÀº¼ö
1362
ÆòÁ¡
   
Ç¥½Ã¿É¼Ç
HTML»ç¿ë | ÀÚµ¿BRűנ| °ø¹é¹®ÀÚÇã¿ë | °¡¿îµ¥Á¤·Ä | °íÁ¤Æø±Û²Ã | ÀÚµ¿URL¸µÅ© | ¸¶¿ì½º¼±ÅÃ
°ü·Ã¸µÅ©01
https://stackoverflow.com/questions/38842507/what-different-between-fixed-rate-and-fixed-delay-in-schedule-spring 
°ü·Ã ¸µÅ©·Î ±âÀçÇÑ ½ºÅÿÀ¹öÇ÷ο쿡´Â À߸øµÈ ´äº¯ÀÌ Ã¤Åà µÇ¾î ÀÖ´Ù.
äÅÃµÈ ´äº¯ÀÇ ¾Æ·¡ ´äº¯ (nikhil7610 °¡ ÀÛ¼ºÇÑ) ÀÌ Á¤È®ÇÑ ´äº¯À̸ç, ±×¿¡ ´ëÇÑ ¼³¸íÀº ¾Æ·¡¿Í °°´Ù.
¡Ü "fixedRate"  : waits for X millis from the start of previous execution before starting next execution.
    If current execution exceeds 'fixedRate' interval, the next execution is queued, but only next one.
    It will not create series of queued executions

    ÀÌÀü ÀÛ¾÷ÀÇ "½ÃÀÛ ½Ã°£" À» ±âÁØÀ¸·Î X ¹Ð¸®Ãʸ¸Å­ ´ë±â ÈÄ ´ÙÀ½ ÀÛ¾÷À» ½ÃÀÛÇÑ´Ù.
    ÀÌÀü ÀÛ¾÷ÀÌ ³¡³ªÁö ¾ÊÀº °æ¿ì, ´ÙÀ½ ÀÛ¾÷Àº Å¥¿¡ µé¾î°¡°Ô µÇ¸ç ÀÌ´Â ´ÙÀ½ 1°³ÀÇ ÀÛ¾÷¿¡¸¸ ÇØ´çµÈ´Ù.
    (Áï ÀÌÀü ÀÛ¾÷ÀÌ ¾Æ¹«¸® ¿À·¡ °É·Áµµ ¿©·¯ °³ÀÇ ÀÛ¾÷ÀÌ Å¥¿¡ µé¾î°¡Áö´Â ¾Ê´Â´Ù)

¡Ü "fixedDelay" : waits for X millis from the end of previous execution before starting next execution.
    Doesn't matter how much time current execution is taking,
    the next execution is started after adding 'fixedDelay' interval to end time of current execution.
    It will not queue next execution.

    ÀÌÀü ÀÛ¾÷ÀÇ "Á¾·á ½Ã°£" À» ±âÁØÀ¸·Î X ¹Ð¸®Ãʸ¸Å­ ´ë±â ÈÄ ´ÙÀ½ ÀÛ¾÷À» ½ÃÀÛÇÑ´Ù.
    ÀÌÀü ÀÛ¾÷ÀÌ ¾Æ¹«¸® ¿À·¡ °É¸°´Ù ÇÏ´õ¶óµµ, ´ÙÀ½ ÀÛ¾÷Àº ÀÌÀü ÀÛ¾÷ÀÌ ³¡³­ ÈÄ fixedDelay ½Ã°£¸¸Å­ ´ë±âÇÏ°í ½ÇÇàµÈ´Ù.
    fixedRate ÀÛ¾÷°ú´Â ´Þ¸® ´ÙÀ½ ÀÛ¾÷ÀÌ Å¥¿¡ µé¾î°¡Áø ¾Ê´Â´Ù.


¡Ü fixedDelay
fixedDelay   : 1000 ms
thread sleep : 3000 ms
     seconds +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---->
             0    1    2    3    4    5    6    7    8    9    10   11   13   14   15   16   
ITERATION #1 |--------------|
ITERATION #2                     |--------------|
ITERATION #3                                         |--------------|
ITERATION #4                                                             |--------------|
...

¡Ü fixedRate
fixedRate    : 1000 ms
thread sleep : 3000 ms
     seconds +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---->
             0    1    2    3    4    5    6    7    8    9    10   11   13   14   15   16   
ITERATION #1 |----+---------|
                  ¡è queued next schedule
ITERATION #2                |----+---------|
                                 ¡è queued next schedule
ITERATION #3                               |----+---------|
                                                ¡è queued next schedule
ITERATION #4                                              |----+---------|
                                                               ¡è queued next schedule
...

¡Ü fixedRate
fixedRate    : 3000 ms
thread sleep : 2000 ms
     seconds +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---->
             0    1    2    3    4    5    6    7    8    9    10   11   13   14   15   16   
ITERATION #1 |---------|
ITERATION #2                |---------|
ITERATION #3                               |---------|
ITERATION #4                                              |---------|
...


½ºÄÉÁÙ ÀÛ¾÷À» ÀÌÀü ÀÛ¾÷°ú »ó°ü¾øÀÌ ÁöÁ¤µÈ ÁֱⰡ µÇ¸é ¹Ù·Î ¼öÇàÇÏ°Ô ÇÏ·Á¸é
@Async + @Scheduled ¾î³ëÅ×À̼ÇÀ» Á¶ÇÕÇÏ¿© ½ºÄÉÁÙÀÌ ºñµ¿±â·Î ¼öÇàµÇ°Ô ÇÏ¸é µÈ´Ù.
½ºÄÉÁÙÀ» ºñµ¿±â·Î ¼öÇàÇϸé, @EnableAsync ¿Í ½º·¹µå Ç® ¼³Á¤ÀÌ µÇ¾î ÀÖ´Ù´Â Àüü ÇÏ¿¡ ¾Æ·¡¿Í °°ÀÌ µ¿ÀÛÇÑ´Ù.
¡Ü fixedRate + @Async
fixedRate    : 1000 ms
thread sleep : 3000 ms
     seconds +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---->
             0    1    2    3    4    5    6    7    8    9    10   11   13   14   15   16   
ITERATION #1 |----+---------|
ITERATION #2      |----+---------|
ITERATION #3           |----+---------|
ITERATION #4                |----+---------|
...

¡Ü fixedDelay + @Async
fixedDelay   : 1000 ms
thread sleep : 3000 ms
     seconds +----+----+----+----+----+----+----+----+----+----+----+----+----+----+----+---->
             0    1    2    3    4    5    6    7    8    9    10   11   13   14   15   16   
ITERATION #1 |--------------|
ITERATION #2      |--------------|
ITERATION #3           |--------------|
ITERATION #4                |--------------|
...

 °Ô½ÃÆÇ ±Û ¸ñ·Ï
No Subject Poster Hits Posted
14439 helix 1409 2019-12-06 00:56:59
14437 helix 2323 2019-10-01 10:57:58
helix 1362 2019-07-03 16:50:25
14282 helix 1852 2018-04-05 10:47:10
14281 helix 1739 2018-04-05 10:31:07
14237 helix 6134 2017-12-01 15:18:39
14236 helix 5866 2017-12-01 14:49:07
14232 helix 4736 2017-11-22 17:56:06
ÄÚ¸àÆ®
ÀÛ¼ºÀÚ
                       
 
zany.kr
  Copyright ¨Ï 2002-2010 Zany's Programming Lab. All Rights Not Reserved.
temporary This Page loads on 0.016 Secs