Lab Task 8
Lab Task 8
1. Create two threads, ThreadA and ThreadB. ThreadA should print odd numbers from
1 to 10, and ThreadB should print even numbers from 2 to 10. Ensure that the
numbers are printed in the correct order, and the output should look like: 1 2 3 4 5 6
7 8 9 10.
2. You want to print numbers from 1 to 10 using three separate threads. Each thread
should print a specific range of numbers, and the threads should run concurrently.
Like- thread1 prints 1-3, thread2 prints 4-7, thread3 prints 8-10.
3. Create a thread class which prints 1-n. Also create three objects of that class.
Implement the above scenario in Java, keeping in mind all kinds of exceptions
possible and ensure context switching. Show the expected output.
4. Write a Java program to get a list of all file/directory names from the given.
5. Write a Java program to check if a file or directory specified by pathname exists or
not.
6. Write a Java program to create a file of the name “student” inside a “university”
directory. And take input(at least 3) into that in- name, id, dept category. Read the
data from the file
7. Copy the data of file in number 3. To another file.