为什么以下代码线程不安全以及如何修复它?
public abstract class BaseResponseHandler extends AsyncHttpResponseHandler {
private static XmlPullParserFactory xmlPullParserFactory;
public static synchronized XmlPullParser newPullParser(String input) throws XmlPullParserException {
if (xmlPullParserFactory == null) {
xmlPullParserFactory = XmlPullParserFactory.newInstance();
}
final XmlPullParser parser = xmlPullParserFactory.newPullParser();
parser.setInput(new StringReader(input));
return parser;
}
}