0% found this document useful (0 votes)
88 views

JP Assignment 4

This document outlines a Java programming assignment covering key threading and I/O concepts: 1) Synchronization is important in Java to allow threads to safely access shared resources. A daemon thread runs in the background to support other threads. sleep() pauses a thread for a set time while wait() pauses until another thread notifies. 2) Thread synchronization allows threads to safely access shared resources using locks and monitors. Threads communicate through waits, notifications, and shared memory. 3) Streams are used for input/output with byte streams handling raw bytes and character streams converting bytes to characters. FileReader reads characters from a file while BufferReader adds buffering.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
88 views

JP Assignment 4

This document outlines a Java programming assignment covering key threading and I/O concepts: 1) Synchronization is important in Java to allow threads to safely access shared resources. A daemon thread runs in the background to support other threads. sleep() pauses a thread for a set time while wait() pauses until another thread notifies. 2) Thread synchronization allows threads to safely access shared resources using locks and monitors. Threads communicate through waits, notifications, and shared memory. 3) Streams are used for input/output with byte streams handling raw bytes and character streams converting bytes to characters. FileReader reads characters from a file while BufferReader adds buffering.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

JAVA PROGRAMMING - ASSIGNMENT - 4

PART-A

1) What is the importance of synchronization in java?


2) What is a daemon thread?
3) Differentiate between sleep () and wait ().
4) How to read data in java file? Discuss.
5) What happen when PrintWriter method receives a string type argument?

PART-B

1. a) What is thread synchronization? Discuss with an example.


b) Explain how communication between threads takes place with a programming example.
2. a) "Threads can be given priorities" - Support this statement with suitable example.
b) Explain various thread states and properties in detail with a neat diagram
3. a) What is a stream? What is the difference between byte streams and character streams? How are
they used to capture input from the user?
b) Differentiate between FileReader and BufferReader.

PROGRAMS:

1. Write a Java program that prints numbers from 1 to 10 line by line after every 5 seconds
2. Write a Java program to demonstrate multithreading operation.
3. Write a java program to implement producer consumer problem.
4. Write a java program to display all odd numbered lines of a text file.
5. Write a program to read user name from console and display some message for that user using
streams.

You might also like