A man who threatened an African neighbour and his friend with a knife in a racially orientated incident has been sent to prison for more than three years.