Abstract:In this paper, the authors discuss the design and implementation of Java multi-threads. A new thread scheduling algorithm, named Preemptive Round-Robin Scheduling with a Free Queue, is presented. Under this policy threads in the free queue are not assigned with a constant priority. Their priority is the same as the highest-priority threads which are in running state. The highest-priority threads and the threads in the free queue are time-sliced scheduled. This algorithm solves the scheduling problem for independent looping thread. To improve the efficiency of thread synchronization, a new design for object lock is presented. It is called the Mixed Hash Object Lock. This design is a tradeoff between the lock efficiency and its space. The experimental results have proved that the design is feasible. Compared with the traditional design, the efficiency for locking and unlocking is high and the space allocated to lock is small.