0% found this document useful (0 votes)
12 views2 pages

Week 7 Practice Questions

app week assignment

Uploaded by

pk6048
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)
12 views2 pages

Week 7 Practice Questions

app week assignment

Uploaded by

pk6048
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/ 2

SRM INSTITUTE OF SCIENCE AND TECHNOLOGY

FACULTY OF ENGINEERING AND TECHNOLOGY


SCHOOL OF COMPUTING
DEPARTMENT OF COMPUTATIONAL INTELLIGENCE
21CSC203P ADVANCED PROGRAMMING PRACTICE

Week 7 – Tutorial Assignment

CONCURRENT PROGRAMMING PARADIGM: THREAD CLASSES AND METHODS

1. Write a java program that implements a multi-thread application that has three threads. First thread
generates random integer every 1 second and if the value is even, second thread computes the square of
the number and prints. If the value is odd, the third thread will print the value of cube of the number.

2. Write a java program for to solve producer consumer problem in which a producer produce a value and
consumer consume the value before producer generate the next value.

3. Write a java program in which thread sleep for 5 sec and change the name of thread.

4. Write a java program in which thread sleep for 6 sec in the loop in reverse order from 5 to 1 and change
the name of thread.

5. Write a java program for multithread in which user thread and thread started from main method
invoked at a time each thread sleep for 1 sec.

6. Write a java program to solve printer synchronization problem in which all the jobs must be completed
in order.

7. Create a java program for the following

Use ThreadA to find number of digits present in the string k and store into variable dc, finally
print the value of dc(output format: ThreadA:digitscount).
Use ThreadB to find number of alphabetic present in the string k and store into variable cc, finally
print the value of cc(output format:ThreadB:digitscount).

8. Create two objects threadobj1 and threadobj2 for the class UserThreadPriority. Set the name of
threadobj1 as “ThreadA” and threadobj2 as “ThreadB”. Get a String and a Character from the user and
assign into UserThreadPriority class variable k and c respectively. Call the start() method for the thread
objects threadobj1 and threadobj2.

9. Write java program using sleep() method of Thread class where the new class thread created from the
previous class is implemented by using sleep method for 10,20,50,70,100 ns

10. Write a java Thread program using Thread Priority for 5 processes and execute the priority order
among the process.

You might also like