Monitor object

Post on 05-Dec-2014

1.575 views 0 download

description

 

Transcript of Monitor object

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

Caller ITEM 1

ITEM 1

ITEM 1

Processor

Active Object

Caller Thread

other-Threads

Process Thread

Passive Object

THREAD 1

THREAD 2

ITEM 1

ITEM 1

ITEM 1

Processor Processor

Passive Object

Each Thread Process

Shared Object

Active Object

Monitor Object

VS

Active Object

Monitor Object

VS

Monitor Object is

Monitor Object is

Part Of Active Object

EXAMPLE

QUEUE

IN Multi-Thread

NEED Synchronization

Mechanisms

ITEM 1

ITEM 2

ITEM 3

ITEM 4

ITEM 5

THREAD 1 THREAD 2

ITEM 1

ITEM 2

ITEM 3

ITEM 4

ITEM 5

THREAD 1 THREAD 2

INSERT

ITEM 1

ITEM 2

ITEM 3

ITEM 4

ITEM 5

THREAD 1 THREAD 2

INSERT INSERT

ITEM 1

ITEM 2

ITEM 3

ITEM 4

ITEM 5

THREAD 1 THREAD 2

INSERT INSERT

BROKEN

No Item In

Queue

No Items

THREAD 1 THREAD 2

Pop

No Items

THREAD 1 THREAD 2

Pop

WAIT

THREAD 1 THREAD 2

Pop

WAIT

ITEM 1

Insert

THREAD 1 THREAD 2

Pop

NOTIFY

ITEM 1

Insert

THREAD 1 THREAD 2

Pop

ITEM 1

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!