UNIT V — String Handling in Java & Multithreaded Programming
Part A — String Handling in Java
1. Introduction
Strings are immutable objects representing sequences of characters. Java provides String,
StringBuffer, StringBuilder, and the CharSequence interface to work with textual data.
2. CharSequence interface
An abstraction for a readable sequence of char values.
3. Class String
Immutable and widely used for text processing in Java.
4. Methods for Extracting Characters
- charAt
- toCharArray
- getChars
5. Comparison, Modifying, Searching Strings
6. Class StringBuffer
Mutable, synchronized version of StringBuilder.
Part B — Multithreaded Programming
1. Introduction
Multithreading allows multiple threads to run concurrently.
2. Need for Threads
For efficiency, responsiveness, parallel processing.
3. Thread Class & Runnable Interface
4. Thread States
NEW, RUNNABLE, BLOCKED, WAITING, TIMED_WAITING, TERMINATED.
5. Priority, Synchronization, Race Conditions, Deadlock
6. Inter-thread Communication
wait(), notify(), notifyAll()
7. Suspending, Resuming, Stopping Threads (Deprecated)
Use interrupt() or flags.