Thursday, September 1, 2005 02:53 AM
I seriously think you should stick to learning the basics first and then worry about thread safety. Learn about types, methods, return values etc. Why should you worry about threads when your code doesn't even compile?
Find some nice tutorials to help you get started. Here are a few resources:
Also, use an IDE, it greatly enhances productivity and points out the most obvious errors (syntax etc.). I recommend Eclipse
, which has a good feature set and is free.
But back to the original question... No, it's not thread safe, because the instance variables are public - any other thread could modify an Address while another is calling compareAddress(). You should consider a) making Address immutable or b) synchronize variable accessor methods. But as I said: start with the basics!