The invention discloses a
timer setting method under the
multithreading environment. On the basis of the traditional increment
timer, one index structure and a double
linked list are introduced in to improve the
time efficiency of the
timer. The traditional increment timer adopts one double
linked list to manage a timer unit according to a time overtime sequence, and the steps of setting a new timer, clearing the timer and carrying out timer overtime judgment are all carried out by the
linked list. When the number of the timer unit is huge, the operations occupy a great quantity of CPU (
central processing unit) resources. According to the index structure introduced by the invention, the timer unit can be quickly looked up and managed according to the unique identification of the timer, first timer units triggered at different time periods are connected by the newly-added double linked
list, the setting operation performance of the new timer is improved, and the timer
time efficiency is improved under the condition that little space overhead is added. The timer setting method under the
multithreading environment, which is disclosed by the invention, has the
advantage that an implementation method is simple and easy to understand, and is suitable for the requirement on the timer under the common environment.