|
@@ -37,7 +37,7 @@ main :: proc(){
|
|
|
// Getting a threads address at index i
|
|
|
t := threadPool[i]
|
|
|
if thread.is_done(t){
|
|
|
- fmt.printf("Thread %d is done\n", arr[t.user_index])
|
|
|
+ fmt.printf("Thread %d is done\n\n", arr[t.user_index])
|
|
|
thread.destroy(t)
|
|
|
// removing address of destroyed thread from out pool
|
|
|
ordered_remove(&threadPool, i)
|
|
@@ -69,7 +69,7 @@ worker :: proc(t: ^thread.Thread){
|
|
|
fmt.printf("work of t%d started\n", arr[t.user_index])
|
|
|
time.sleep(time.Second)
|
|
|
fmt.printf("work of t%d completed\n", arr[t.user_index])
|
|
|
- fmt.println()
|
|
|
+ //fmt.println()
|
|
|
|
|
|
//sync.unlock(myMutex) // unlocking for other threads to use it
|
|
|
sync.mutex_unlock(&myMutex) // unlocking for other threads to use it
|
|
@@ -81,30 +81,28 @@ worker :: proc(t: ^thread.Thread){
|
|
|
odin run thr3.odin -file
|
|
|
work of t1 started
|
|
|
work of t1 completed
|
|
|
-
|
|
|
Thread 1 is done
|
|
|
+
|
|
|
work of t2 started
|
|
|
work of t2 completed
|
|
|
-
|
|
|
Thread 2 is done
|
|
|
+
|
|
|
work of t3 started
|
|
|
work of t3 completed
|
|
|
-
|
|
|
Thread 3 is done
|
|
|
|
|
|
|
|
|
odin run thr3.odin -file
|
|
|
work of t2 started
|
|
|
work of t2 completed
|
|
|
-
|
|
|
Thread 2 is done
|
|
|
+
|
|
|
work of t1 started
|
|
|
work of t1 completed
|
|
|
-
|
|
|
Thread 1 is done
|
|
|
+
|
|
|
work of t3 started
|
|
|
work of t3 completed
|
|
|
-
|
|
|
Thread 3 is done
|
|
|
|
|
|
*/
|