Threading

9
Threads Melick R. Baranasooriya http://melick- rajee.blogspot.com/

Transcript of Threading

Page 1: Threading

ThreadsMelick R. Baranasooriya

http://melick-rajee.blogspot.com/

Page 2: Threading

ThreadO Operating systems

O separate the different applicationsO operating system allocates processor

time

O Thread maintainsO exception handlersO a scheduling priority

Page 3: Threading

When to use ?O Rich user experienceO Divide the Work load

O Communicate overO networkO Web serverO database

Page 4: Threading

When to use ? ..O Operations that take a large amount

of timeO Distinguish tasks

O  high-priorityO  manages time-critical tasksO low-priority thread

O May consume memory (< than few)

Page 5: Threading

Simple Example

Page 6: Threading

Thread Operations

Join()

Abort()Sleep()

Interrupt()

WaitOne()

Page 7: Threading

Cross Thread Operations

O GUI is running in a separate threadO If we use threads

O It is running in separate Thread

Page 8: Threading

Thread Safe OperationsO Lock

O MutexO Semaphore

O Limits the number of threads that can access a resource

O Monitor

Page 9: Threading

Thank You!