Method and system for handling queues in communication networks, corresponding computer program product