Guest User

Untitled

a guest
Jan 20th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.64 KB | None | 0 0
  1. /**
  2. * A representation of a thread's state. A given thread may only be in one
  3. * state at a time.
  4. */
  5. public enum State {
  6. /**
  7. * The thread has been created, but has never been started.
  8. */
  9. NEW,
  10. /**
  11. * The thread may be run.
  12. */
  13. RUNNABLE,
  14. /**
  15. * The thread is blocked and waiting for a lock.
  16. */
  17. BLOCKED,
  18. /**
  19. * The thread is waiting.
  20. */
  21. WAITING,
  22. /**
  23. * The thread is waiting for a specified amount of time.
  24. */
  25. TIMED_WAITING,
  26. /**
  27. * The thread has been terminated.
  28. */
  29. TERMINATED
  30. }
  31.  
  32. public synchronized void start() {
  33. /**
  34. * This method is not invoked for the main method thread or "system"
  35. * group threads created/set up by the VM. Any new functionality added
  36. * to this method in the future may have to also be added to the VM.
  37. *
  38. * A zero status value corresponds to state "NEW".
  39. */
  40. // Android-changed: throw if 'started' is true
  41. if (threadStatus != 0 || started)
  42. throw new IllegalThreadStateException();
  43.  
  44. /* Notify the group that this thread is about to be started
  45. * so that it can be added to the group's list of threads
  46. * and the group's unstarted count can be decremented. */
  47. group.add(this);
  48.  
  49. started = false;
  50. try {
  51. nativeCreate(this, stackSize, daemon);
  52. started = true;
  53. } finally {
  54. try {
  55. if (!started) {
  56. group.threadStartFailed(this);
  57. }
  58. } catch (Throwable ignore) {
  59. /* do nothing. If start0 threw a Throwable then
  60. it will be passed up the call stack */
  61. }
  62. }
  63. }
  64.  
  65. public void run()
Add Comment
Please, Sign In to add comment