* <p>This provides an easy abstraction to read bits at a time from a sequence of bytes, where the\r
* number of bits read is not often a multiple of 8.</p>\r
*\r
- * <p>This class is not thread-safe.</p>\r
+ * <p>This class is thread-safe but not reentrant. Unless the caller modifies the bytes array\r
+ * it passed in, in which case all bets are off.</p>\r
*\r
* @author Sean Owen\r
*/\r
* <p>For an interesting discussion of this issue, see\r
* <a href="http://webdiis.unizar.es/~neira/12082/thresholding.pdf">this paper</a>.</p>\r
*\r
- * NOTE: This class is not threadsafe.\r
+ * NOTE: This class is not thread-safe.\r
*\r
* @author Sean Owen\r
* @author dswitkin@google.com (Daniel Switkin)\r
*/
public abstract class GridSampler {
- private static GridSampler gridSampler = null;
+ private static GridSampler gridSampler = new DefaultGridSampler();
/**
* Sets the implementation of {@link GridSampler} used by the library. One global
* in the whole lifetime of the JVM. For instance, an Android activity can swap in
* an implementation that takes advantage of native platform libraries.
*
- * @param newGridSampler
+ * @param newGridSampler The platform-specific object to install.
*/
public static void setGridSampler(GridSampler newGridSampler) {
if (newGridSampler == null) {
* @return the current implementation of {@link GridSampler}
*/
public static GridSampler getInstance() {
- // No real point in trying to make this thread-safe;
- // doesn't matter if a second instance is created
- if (gridSampler == null) {
- gridSampler = new DefaultGridSampler();
- }
return gridSampler;
}
* markers at three corners of a QR Code.</p>\r
*\r
* <p>This class is not thread-safe and should not be reused.</p>\r
+ * TODO(dswitkin): Is this comment still true? I don't see any global variables for example.\r
*\r
* <p>In contrast to {@link FinderPatternFinder}, this class will return an array of all possible\r
* QR code locations in the image.</p>\r