Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Use SystemClock.sleep()
Avoid try/catch InterruptedException of Thread.sleep().
  • Loading branch information
rom1v committed Apr 19, 2013
commit 2045e41b65bb741a00d27de3b592240ee6f696d7
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import org.androidannotations.test15.instancestate.MySerializableBean;

import android.app.Activity;
import android.os.SystemClock;

@EActivity
public class ThreadActivity extends Activity {
Expand All @@ -50,12 +51,9 @@ void emptyDelayedBackgroundMethod() {

@Background(serial="test")
void addSerializedBackgroundMethod(List<Integer> list, int i, Semaphore sem) {
/* wait a random delay to increase the probability of wrong order if buggy */
try {
/* wait between 0 and 20 milliseconds */
Thread.sleep(new Random().nextInt(20));
} catch (InterruptedException e) {}

/* wait a random delay (between 0 and 20 milliseconds) to increase the
* probability of wrong order if buggy */
SystemClock.sleep(new Random().nextInt(20));
list.add(i);
sem.release();
}
Expand Down