অধ্যায় ৭ঃ মাল্টিথ্রেড প্রোগ্রামিং
রচনামূলক
১. Multithread programming method ব্যবহারপূর্বক Java তে একটি প্রোগ্রাম লেখ।
উত্তরঃ
class A extends Thread //Thread A { public void run() { for ( int in 1; i<=5; i=i+2) { System.out.printin ("Inside Thread A: In+i); } System.out.printin ("Exit from A”): } } class B extends Thread q//Thread B { public void run() { for ( int ]=1; j<=5; j=j+2) { System.out.println("Inside Thread B: j="+j); } System.out.printin ("Exit from B"); } } class MultiThread //Main Thread { public static void main(String args []) { A Th1=new A(); //Creating Object of Thread A B Th2=new B(); //Creating Object of Thread B System.out.printin ("Starting Thread A"); Th1.start(); System.out.printin ("Starting Thread B”); Th2.start(); System.out.println("Exit from the Main Thread "); } }