Course List: http://www.c-jump.com/bcc/

Multi-Threading


  1. Java Multi-Threading Functionality
  2. Discussion and further reference
  3. Typical uses for threads
  4. Creating threads
  5. Thread -- Runnable -- Object
  6. Two ways to create a thread
  7. The life cycle of a thread
  8. Thread states
  9. The Thread class
  10. Common methods of the Thread class
  11. Creating a thread
  12. Example: Creating a thread
  13. IOThread -- thread class example
  14. Sample output for the IOThread example
  15. Creating a thread implementing Runnable interface
  16. Example: IOTask class implementing the Runnable interface
  17. Starting Runnable interface thread example
  18. Thread interruption
  19. Thread interruption - InterruptedException
  20. Thread interruption - manual checks
  21. Example: interrupting a thread
  22. Example: Counter class gets interrupted
  23. Example: Counter class sample output
  24. The synchronized keyword
  25. The synchronized methods example
  26. The syntax for creating a synchronized method
  27. A synchronized method that increments an instance variable
  28. Synchronized blocks in instance methods
  29. Object class methods for inter-thread communication
  30. Example: wait() -- notifyAll()
  31. Thread setPriority method
  32. Setting thread priority example
  33. Example: Order Queue application
  34. Sample output from the Order Queue application
  35. Classes used by the Order Queue application
  36. Order Queue sequence diagram
  37. Further reading

1. Java Multi-Threading Functionality



2. Discussion and further reference



3. Typical uses for threads



4. Creating threads



5. Thread -- Runnable -- Object



6. Two ways to create a thread


  1. Inherit the Thread class

  2. Implement the Runnable interface, then

     


7. The life cycle of a thread



8. Thread states



9. The Thread class



10. Common methods of the Thread class



11. Creating a thread



12. Example: Creating a thread



13. IOThread -- thread class example



14. Sample output for the IOThread example



15. Creating a thread implementing Runnable interface


  1. Create a class that implements the Runnable interface.

  2. Implement the run() method to perform the desired task.

  3. Create the thread by supplying an instance of the Runnable class to the Thread constructor.

  4. Call the start() method of the thread object.

     


16. Example: IOTask class implementing the Runnable interface



17. Starting Runnable interface thread example



18. Thread interruption



19. Thread interruption - InterruptedException



20. Thread interruption - manual checks



21. Example: interrupting a thread



22. Example: Counter class gets interrupted



23. Example: Counter class sample output



24. The synchronized keyword



25. The synchronized methods example



26. The syntax for creating a synchronized method



27. A synchronized method that increments an instance variable



28. Synchronized blocks in instance methods



29. Object class methods for inter-thread communication



30. Example: wait() -- notifyAll()



31. Thread setPriority method



32. Setting thread priority example



33. Example: Order Queue application



34. Sample output from the Order Queue application



35. Classes used by the Order Queue application



36. Order Queue sequence diagram



37. Further reading