Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

Core Java Interview Questions and Answers

Test your skills through the online practice test: Core Java Quiz Online Practice Test

Ques 141. What is a 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.

Is it helpful? Add Comment View Comments
 

Ques 142. What is a thread?

Thread is a block of code which can execute concurrently with other threads in the JVM.

Is it helpful? Add Comment View Comments
 

Ques 143. What is the algorithm used in Thread scheduling?

Fixed priority scheduling.

Is it helpful? Add Comment View Comments
 

Ques 144. What are the different level lockings using the synchronization keyword?

Is it helpful? Add Comment View Comments
 

Ques 145. What are the ways in which you can instantiate a thread?

Using Thread class By implementing the Runnable interface and giving that handle to the Thread class.

class RunnableThread implements Runnable {
	Thread runner;
	
	public RunnableThread() {
	}
	
	public RunnableThread(String threadName) {
		runner = new Thread(this, threadName); // (1) Create a new thread.
		System.out.println(runner.getName());
		runner.start(); // (2) Start the thread.
	}

	public void run() {
		//Display info about this particular thread
		System.out.println(Thread.currentThread());
	}
}

Is it helpful? Add Comment View Comments
 

Most helpful rated by users:

©2024 WithoutBook