  Terahertz (THz) wireless networks are expected to catalyze the beyond fifth
generation (B5G) era. However, due to the directional nature and the
line-of-sight demand of THz links, as well as the ultra-dense deployment of THz
networks, a number of challenges that the medium access control (MAC) layer
needs to face are created. In more detail, the need of rethinking user
association and resource allocation strategies by incorporating artificial
intelligence (AI) capable of providing "real-time" solutions in complex and
frequently changing environments becomes evident. Moreover, to satisfy the
ultra-reliability and low-latency demands of several B5G applications, novel
mobility management approaches are required. Motivated by this, this article
presents a holistic MAC layer approach that enables intelligent user
association and resource allocation, as well as flexible and adaptive mobility
management, while maximizing systems' reliability through blockage
minimization. In more detail, a fast and centralized joint user association,
radio resource allocation, and blockage avoidance by means of a novel
metaheuristic-machine learning framework is documented, that maximizes the THz
networks performance, while minimizing the association latency by approximately
three orders of magnitude. To support, within the access point (AP) coverage
area, mobility management and blockage avoidance, a deep reinforcement learning
(DRL) approach for beam-selection is discussed. Finally, to support user
mobility between coverage areas of neighbor APs, a proactive hand-over
mechanism based on AI-assisted fast channel prediction is~reported.
