Incremental reorganization of hash tables includes a copy phase and a
clean phase. In the copy phase, used entries from an alternate hash table (AHT)
are copied to a current hash table (CHT). During copying, hash table operations
are allowed to access both tables. In the clean phase, entries in the AHT are marked
as empty, and hash table operations are allowed to access only the CHT. Once all
used entries have been copied from the AHT to the CHT, the clean phase begins.
Once all entries in the AHT have been marked as empty during the clean phase, the
two tables are switched and the copy phase begins. The copying or cleaning occurs
with every hash table operation, a number of hash table operations, or a number
based on analysis of recent hash table operations. Copying also occurs by avoiding
copying of deleted or expired entries in the AHT. The present invention is suited
to use in multithreaded real-time systems.