Changes

Jump to: navigation, search

Computer Science/162/proj1

383 bytes added, 00:03, 5 October 2008
Testing: one of three actions
===Testing===
* {{c|Condition2.java}} was tested using a class called {{c|CondThread}}, which implements {{c|Runnable}}. The class is instantiated with an integer {{c|iterations}}, a lock, a {{c|Condition2}} variable to call {{c|sleep()}} on, and a {{c|Condition2}} variable to call {{c|wake()}} on. When a {{c|CondThread}} runs, it acquires the lock, then enters a for-loop of 6 iterations. On each iteration, the thread will print out a debug statement noting that the current thread is on the ith iteration. When the loop iteration number is equal to {{c|iterations}}, threads can take one of three actions:*#If the thread's ID is '0', then that thread is the waking thread and calls {{c|wake()}} on its second condition variable.*#If the thread's ID is '0-all', it calls {{c|wakeAll()}} on its second condition variable*#Otherwise, it goes to sleep on its first condition variable. Using the output, we verify that the threads all run in the correct order and all execute to completion.
* Sleep several threads on the condition variable. Upon waking, these threads should print a unique statement and perform a {{c|wake()}} on the condition variable. Have one thread perform an initial {{c|wake()}} on the condition variable and verify that all threads are executed.
* Sleep several threads on the condition variable, then have one final thread wake them all with {{c|wakeAll()}}. Verify that all threads have woken up via console print statements.
1,277
edits

Navigation menu