-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlr4.py
More file actions
37 lines (31 loc) · 901 Bytes
/
lr4.py
File metadata and controls
37 lines (31 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import threading
import numpy as np
import time
import logging
def convolution():
global arr
lst = []
logging.debug('Locked')
lock.acquire()
try:
High = len(arr)
for i in range(0, High, 2):
lst.append(np.fmax(arr[i], arr[i+1]))
time.sleep(0.01)
print(lst)
print(len(lst))
arr = lst
finally:
logging.debug('Unlocked')
lock.release()
if __name__ == "__main__":
logging.basicConfig(level=logging.DEBUG,
format='(%(threadName)-1s) %(message)s', )
lock = threading.Lock()
global arr
arr = np.random.randint(100, size=1024)
event = threading.Event()
ThCount = 10
for t in range(ThCount):
#threading.Thread(target=convolution, args=(lst, (le/ThCount)*t, (le/ThCount)*(t+1), )).start()
threading.Thread(target=convolution).start()