Friday, 2 August 2013

Java/Core Java Interview question: - What are native threads, working thread and green thread?

Native Threads: -
  • Native threads use the operating system's native ability to manage multi-threaded processes - in particular, they use the pthread library
  • The kernel schedules and manages the various threads that make up the process

Working Thread: - 
  • In working thread scheme, allocates one thread to execute one task.
  • When the task is complete, the thread may return to a thread pool for later use. In this scheme a thread may execute arbitrary tasks, which are passed in the form of a Runnable method argument, typically execute()
  • The runnable tasks are usually stored in a queue until a thread host is available to run them.
  • The worker thread design pattern is usually used to handle many concurrent tasks where it is not important which finishes first and no single task needs to be coordinated with another. The task queue controls how many threads run concurrently to improve the overall performance of the system. However, a worker thread framework requires relatively complex programming to set up, so should not be used where simpler threading techniques can achieve similar results.

Green Thread: - 
  • A green thread refers to a mode of operation for the Java Virtual Machine (JVM) in which all code is executed in a single operating system thread. If the Java program has any concurrent threads, the JVM manages multi-threading internally rather than using other operating system threads
  • There is a significant processing overhead for the JVM to keep track of thread states and swap between them, so green thread mode has been deprecated and removed from more recent Java implementations. Current JVM implementations make more efficient use of native operating system threads

Also see the following Java video on Google Window Toolkit (GWT).


10 comments:


  1. This information is impressive; I am inspired with your post writing style & how continuously you describe this topic.


    Pawn Shop

    Pawn Loans

    Pawn Shops

    Pawn Loan

    Pawn Shop near me

    ReplyDelete
  2. Its a wonderful post and very helpful, thanks for all this information. You are including better information regarding this topic in an effective way.Thank you so much

    Personal Installment Loans
    Title Car loan
    Cash Advance Loan

    ReplyDelete
  3. It is an obligation of gratitude to share information, continue the great work ... I sincerely enjoy researching your website. great asset ...pmp certification in malaysia

    ReplyDelete
  4. Your this webpage is on legitimate steroids in UK so you are mentioned to visit the site for purchasing just authentic steroids in United Kingdom. I will be glad to see you out there this decent post here.
    iot courses in delhi

    ReplyDelete
  5. These musings just knocked my socks off. I am happy you have posted this.
    training provider in malaysia

    ReplyDelete
  6. I figure it could be more broad in the event that you get a football sports movement
    360DigiTMG data analytics course

    ReplyDelete
  7. We are really grateful for your blog post. You will find a lot of approaches after visiting your post. Great work
    business analytics course

    ReplyDelete