CSE 8B Chapter Notes - Chapter 30.1-30.4: Circular Buffer
Document Summary
Multithreading enables multiple tasks in program to be executed concurrently. Program can have many tasks run concurrently. Thread == flow of execution, from beginning to end, of a task: mechanism for running task. Multithreading makes program more responsive and interactive and enhances performance ie. typing in a word document while simultaneously printing something. Java allows programmer to create additional threads to run concurrent tasks: tasks are instances of runnable interface eg runnable object. Thread == object that facilitates execution of task. Task class must implement runnable interface: must run from a thread. Runnable interface has run() run() tells how thread will run. // custom task class public class taskclass implements runnable { public taskclass() { Taskclass task = new taskclass(); // or runnable task = new taskclass(); Thread thread = new thread(task); // creates thread for task thread. start(); Thread class contains ctors for creating threads for tasks and methods for controlling threads.