diff options
Diffstat (limited to 'src/main/java/com/keuin/kbackupfabric/operation/abstracts/AbstractAsyncOperation.java')
-rw-r--r-- | src/main/java/com/keuin/kbackupfabric/operation/abstracts/AbstractAsyncOperation.java | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/main/java/com/keuin/kbackupfabric/operation/abstracts/AbstractAsyncOperation.java b/src/main/java/com/keuin/kbackupfabric/operation/abstracts/AbstractAsyncOperation.java index f1a19de..bb0c704 100644 --- a/src/main/java/com/keuin/kbackupfabric/operation/abstracts/AbstractAsyncOperation.java +++ b/src/main/java/com/keuin/kbackupfabric/operation/abstracts/AbstractAsyncOperation.java @@ -1,6 +1,10 @@ package com.keuin.kbackupfabric.operation.abstracts; -public abstract class AbstractAsyncOperation extends AbstractSerializedOperation { +/** + * A basic async operation, but not invokable. + * If you want a invokable interface (InvokableOperation), use InvokableAsyncOperation instead. + */ +public abstract class AbstractAsyncOperation extends AbstractSerialOperation { private final Thread thread; private final String name; @@ -14,7 +18,7 @@ public abstract class AbstractAsyncOperation extends AbstractSerializedOperation /** * Start the worker thread. * - * @return true if succeed starting, false if already started. + * @return true if succeed starting, false if this operation is already started, or the sync method failed. */ @Override protected final boolean operate() { @@ -30,13 +34,16 @@ public abstract class AbstractAsyncOperation extends AbstractSerializedOperation /** * Implement your async operation here. - * When this method returns, the operation must finish. + * After starting the operation, this method will be run in another thread after the sync method returns. + * When this method returns, the operation must have been finished. */ protected abstract void async(); /** * If necessary, implement your sync operations here. * It will be invoked before starting the async thread. + * If this method failed, the async method will not be invoked. + * @return whether this method succeed. */ protected boolean sync() { return true; |