Locks Programming CSCI 201 Principles of Software Development

  • Slides: 5
Download presentation
Locks Programming CSCI 201 Principles of Software Development Jeffrey Miller, Ph. D. jeffrey. miller@usc.

Locks Programming CSCI 201 Principles of Software Development Jeffrey Miller, Ph. D. jeffrey. miller@usc. edu

Outline • Locks Program USC CSCI 201 L

Outline • Locks Program USC CSCI 201 L

Locks Program ▪ Write three programs – a server program, a client program, and

Locks Program ▪ Write three programs – a server program, a client program, and a main program ▪ The client program should communicate with the server program and add a value into an Array. List ▪ The server program will maintain the Array. List and return the entire list back to the client ▪ The main program should instantiate 100 clients and execute them all as threads concurrently › Without any synchronization, this may return lists that do not have the number just added at the end ▪ Implement synchronization using locks in the server and possibly in the client USC CSCI 201 L 3/5

Locks Program ▪ Java has a Lock interface that is implemented by the Reentrant.

Locks Program ▪ Java has a Lock interface that is implemented by the Reentrant. Lock and Read. Write. Lock ▪ We are going to now create our own implementation of the java. util. concurrent. locks. Lock interface USC CSCI 201 L 4/5

Locks Program ▪ Test your implementation of the Lock by using your Lock instead

Locks Program ▪ Test your implementation of the Lock by using your Lock instead of the Java Reentrant. Lock in the server program › Note: You may need to modify your Lock code to make it reentrant, meaning that you do not need to acquire the lock again to get into another critical section of code that requires the same lock that you have already acquired USC CSCI 201 L 5/5