কম্পিউটার টিউটোরিয়াল

জাভা ৯-এ প্রসেস API-র কোর লাইব্রেরি পরিবর্তন (Core Library Changes)


জাভা ৯-এ, প্রসেসের PID নেটিভ কল দিয়ে রিট্রিভ করা যায় এবং এটি ProcessHandle-এর মাধ্যমে অর্জনযোগ্য। আমরা বর্তমানে চলমান জাভা প্রসেস (JVM) এবং Info (ProcessHandle-এর ইনার ক্লাস) ক্লাস সম্পর্কে তথ্য পেতে পারি যেটি প্রসেসের বিস্তারিত ধারণ করে। আমরা সিস্টেমে বর্তমানে চলমান সব প্রসেসের একটি স্ন্যাপশট (snapshot) ও রিটার্ন করতে পারি।

উদাহরণ

import java.lang.ProcessHandle.Info;

public class ProcessAPIChanges {
    public void detailedAPIInfo(ProcessHandle processHandle) {
        Info processInfo = processHandle.info();
        System.out.println("Detailed Process Info is Provided Below: ");
        System.out.println("[Executable Name] " + processInfo.command().get());
        System.out.println("[User Name] " + processInfo.user().get());
        System.out.println("[Start Time] " + processInfo.startInstant().get().toString());
    }
    
    public static void main(String args[]) {
        System.out.println("Process API Changes (Core Library) ");
        ProcessAPIChanges processAPIChanges = new ProcessAPIChanges();
        ProcessHandle processHandle = ProcessHandle.current();
        System.out.println("[Current Process Id] " + processHandle.pid());
        processAPIChanges.detailedAPIInfo(processHandle);
        
        ProcessHandle.allProcesses()
            .filter(ph -> ph.info().command().isPresent())
            .limit(4).forEach((process) -> processAPIChanges.detailedAPIInfo(process));
    }
}

আউটপুট

Process API Changes (Core Library) 
[Current Process Id] 5724 
Detailed Process Info is Provided Below: 
[Executable Name] C:\Program Files\Java\jdk-9.0.4\bin\java.exe 
[User Name] Tutorialspoint\User 
[Start Time] 2020-04-01T07:35:43.152Z 
Detailed Process Info is Provided Below: 
[Executable Name] C:\WINDOWS\System32\taskhostex.exe 
[User Name] Tutorialspoint\User 
[Start Time] 2020-04-01T04:14:36.241Z 
Detailed Process Info is Provided Below: 
[Executable Name] C:\Program Files\Synaptics\SynTP\SynTPEnh.exe 
[User Name] Tutorialspoint\User 
[Start Time] 2020-04-01T04:14:36.257Z 
Detailed Process Info is Provided Below: 
[Executable Name] C:\WINDOWS\explorer.exe 
[User Name] Tutorialspoint\User 
[Start Time] 2020-04-01T04:14:36.335Z 
Detailed Process Info is Provided Below: 
[Executable Name] C:\Program Files (x86)\Dell Wireless\Bluetooth Suite\BtvStack.exe 
[User Name] Tutorialspoint\User 
[Start Time] 2020-04-01T04:14:51.594Z

  1. জাভা ৯-এ try-with-resources-এর উন্নতি

  2. জাভা ৯-এ Stream API-তে যোগ করা নতুন ফিচারগুলো

  3. জাভা ৯-এ যোগ করা প্রধান ফিচার ও উন্নতিগুলো

  4. জাভাতে Process ক্লাসের উদ্দেশ্য