SlideShare ist ein Scribd-Unternehmen logo
1 von 50
Downloaden Sie, um offline zu lesen
Monitor Object

          charsyam@naver.com
Multiple Threads
Multiple Threads
          Shared Object
Thread-Safe
Passive-Object
Thread-Safe
         Passive-Object
Pattern
Active Object
 THREAD 1       THREAD 2
                     Processor
   Caller       ITEM 1
                ITEM 1
                ITEM 1
Active Object

 Caller Thread
            other-Threads
 Process Thread
Passive Object
 THREAD 1            THREAD 2
Processor              Processor
            ITEM 1
            ITEM 1
            ITEM 1
Passive Object

 Each Thread Process
          Shared Object
Active Object
          VS
         Monitor Object
Active Object
          VS
         Monitor Object
Monitor Object is
Monitor Object is
  Part Of Active Object
EXAMPLE
QUEUE
IN
Multi-Thread
NEED
Synchronization
  Mechanisms
THREAD 1   ITEM 1   THREAD 2
           ITEM 2
           ITEM 3
           ITEM 4
           ITEM 5
THREAD 1      ITEM 1   THREAD 2
              ITEM 2
     INSERT
              ITEM 3
              ITEM 4
              ITEM 5
THREAD 1      ITEM 1   THREAD 2
              ITEM 2
     INSERT
              ITEM 3   INSERT


              ITEM 4
              ITEM 5
THREAD 1      ITEM 1   THREAD 2
              ITEM 2
     INSERT
              ITEM 3   INSERT


              ITEM 4
              ITEM 5

                 BROKEN
No Item
   In
 Queue
THREAD 1              THREAD 2

     Pop


           No Items
THREAD 1              THREAD 2

     Pop


           No Items
WAIT
THREAD 1   ITEM 1   THREAD 2
                     Insert

     Pop




WAIT
THREAD 1   ITEM 1   THREAD 2
                     Insert

     Pop




NOTIFY
THREAD 1   ITEM 1   THREAD 2
     Pop
Monitor
 Object
With
Thread-Safe
 Interface
External Interface
Thread-Safe Interface
Lock and Notify – 1/2
Lock and Notify – 2/2
Lock and Notify – 2/2
Empty and Full
put
Get
SYNCH_STRATEGY 1/2
SYNCH_STRATEGY 2/2
Connection
   Pool
Multi-Thread
   Queue
Benefits
Simplification of concurrency control
Simplification of scheduling method
execution
Benefits
Simplification of concurrency control
Simplification of scheduling method
execution
Liabilities
Complicated extensibility of coupling
with Monitor Object’s
Inheritance anomaly
Nested Monitor Lockout
Liabilities
Complicated extensibility of coupling
with Monitor Object’s
Inheritance anomaly
Nested Monitor Lockout
Liabilities
Complicated extensibility of coupling
with Monitor Object’s
Inheritance anomaly
Nested Monitor Lockout
THANK
 YOU!

Weitere ähnliche Inhalte

Andere mochten auch

Andere mochten auch (6)

Proactor
ProactorProactor
Proactor
 
Process
ProcessProcess
Process
 
Publisher subscriber pattern
Publisher subscriber patternPublisher subscriber pattern
Publisher subscriber pattern
 
Scalable
ScalableScalable
Scalable
 
Gearman
GearmanGearman
Gearman
 
Refactoring(inline class, Hide delegate, remove middle man)
Refactoring(inline class, Hide delegate, remove middle man)Refactoring(inline class, Hide delegate, remove middle man)
Refactoring(inline class, Hide delegate, remove middle man)
 

Mehr von DaeMyung Kang

How to use redis well
How to use redis wellHow to use redis well
How to use redis wellDaeMyung Kang
 
The easiest consistent hashing
The easiest consistent hashingThe easiest consistent hashing
The easiest consistent hashingDaeMyung Kang
 
How to name a cache key
How to name a cache keyHow to name a cache key
How to name a cache keyDaeMyung Kang
 
Integration between Filebeat and logstash
Integration between Filebeat and logstash Integration between Filebeat and logstash
Integration between Filebeat and logstash DaeMyung Kang
 
How to build massive service for advance
How to build massive service for advanceHow to build massive service for advance
How to build massive service for advanceDaeMyung Kang
 
Massive service basic
Massive service basicMassive service basic
Massive service basicDaeMyung Kang
 
Data Engineering 101
Data Engineering 101Data Engineering 101
Data Engineering 101DaeMyung Kang
 
How To Become Better Engineer
How To Become Better EngineerHow To Become Better Engineer
How To Become Better EngineerDaeMyung Kang
 
Kafka timestamp offset_final
Kafka timestamp offset_finalKafka timestamp offset_final
Kafka timestamp offset_finalDaeMyung Kang
 
Kafka timestamp offset
Kafka timestamp offsetKafka timestamp offset
Kafka timestamp offsetDaeMyung Kang
 
Data pipeline and data lake
Data pipeline and data lakeData pipeline and data lake
Data pipeline and data lakeDaeMyung Kang
 
webservice scaling for newbie
webservice scaling for newbiewebservice scaling for newbie
webservice scaling for newbieDaeMyung Kang
 

Mehr von DaeMyung Kang (20)

Count min sketch
Count min sketchCount min sketch
Count min sketch
 
Redis
RedisRedis
Redis
 
Ansible
AnsibleAnsible
Ansible
 
Why GUID is needed
Why GUID is neededWhy GUID is needed
Why GUID is needed
 
How to use redis well
How to use redis wellHow to use redis well
How to use redis well
 
The easiest consistent hashing
The easiest consistent hashingThe easiest consistent hashing
The easiest consistent hashing
 
How to name a cache key
How to name a cache keyHow to name a cache key
How to name a cache key
 
Integration between Filebeat and logstash
Integration between Filebeat and logstash Integration between Filebeat and logstash
Integration between Filebeat and logstash
 
How to build massive service for advance
How to build massive service for advanceHow to build massive service for advance
How to build massive service for advance
 
Massive service basic
Massive service basicMassive service basic
Massive service basic
 
Data Engineering 101
Data Engineering 101Data Engineering 101
Data Engineering 101
 
How To Become Better Engineer
How To Become Better EngineerHow To Become Better Engineer
How To Become Better Engineer
 
Kafka timestamp offset_final
Kafka timestamp offset_finalKafka timestamp offset_final
Kafka timestamp offset_final
 
Kafka timestamp offset
Kafka timestamp offsetKafka timestamp offset
Kafka timestamp offset
 
Data pipeline and data lake
Data pipeline and data lakeData pipeline and data lake
Data pipeline and data lake
 
Redis acl
Redis aclRedis acl
Redis acl
 
Coffee store
Coffee storeCoffee store
Coffee store
 
Scalable webservice
Scalable webserviceScalable webservice
Scalable webservice
 
Number system
Number systemNumber system
Number system
 
webservice scaling for newbie
webservice scaling for newbiewebservice scaling for newbie
webservice scaling for newbie
 

Monitor object