Document thread safety

This commit is contained in:
Graham Lea
2020-04-10 11:22:49 +10:00
committed by GitHub
parent b413423d05
commit d06758d092
2 changed files with 8 additions and 0 deletions

View File

@@ -30,6 +30,11 @@ import okio.BufferedSource;
/**
* Converts Java values to JSON, and JSON values to Java.
*
* <p>JsonAdapter instances provided by Moshi are thread-safe, meaning multiple threads can safely
* use a single instance concurrently.
*
* <p>Custom JsonAdapter implementations should be designed to be thread-safe.
*/
public abstract class JsonAdapter<T> {
@CheckReturnValue public abstract @Nullable T fromJson(JsonReader reader) throws IOException;

View File

@@ -39,6 +39,9 @@ import static com.squareup.moshi.internal.Util.typeAnnotatedWithAnnotations;
/**
* Coordinates binding between JSON values and Java objects.
*
* <p>Moshi instances are thread-safe, meaning multiple threads can safely use a single instance
* concurrently.
*/
public final class Moshi {
static final List<JsonAdapter.Factory> BUILT_IN_FACTORIES = new ArrayList<>(5);