Skip to content

Instantly share code, notes, and snippets.

@alvindizon
Created October 10, 2019 05:22
Show Gist options
  • Save alvindizon/4e9fd9a11c4478cea9db14f3b0b0797e to your computer and use it in GitHub Desktop.
Save alvindizon/4e9fd9a11c4478cea9db14f3b0b0797e to your computer and use it in GitHub Desktop.
safe lazy initialization example
public class UDPClient {
private static final String TAG = UDPClient.class.getSimpleName();
private static class Holder{
public static UDPClient udpClient = new UDPClient();
}
public static UDPClient getUdpClient() {
return Holder.udpClient;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment