class Msg:
    def __init__(self,type,value):
        self.type = type
        self.value = value

exitFlag = []
MsgQueue = []


def Msgfunction():

    global  MsgQueue,exitFlag
    for i in range(4):
        type = random.randint(0, 3)
        value = 0
        if type == 0:
            value = random.randint(0, 2)
            if lock.acquire():
                exitFlag.append(1)
                lock.release()
        if type == 2:
            value = random.randint(BOTTOM,TOP-1)
        if type == 3:
            value = random.randint(BOTTOM+1,TOP)
        if type == 1:
            value = random.randint(BOTTOM, TOP)

        TIME = random.randint(1, 8)
        m = Msg(type, value)
        if lock.acquire():
            MsgQueue.append(m)
            print("Создать кодировку сообщения:"+ str([m.type,m.value]))
            lock.release()
        time.sleep(TIME)
