Tuesday, December 6, 2011

Check at what techniques your OS is working through Java.

There are two major types of scheduling techniques in the modern operating systems: round-robin and time-slicing.Now how can you identify at what techniques your OS is working through Java.

class Thready {
public static void main( String args [] ) {
new MyThread("A").start();
new MyThread("B").start();
}
}

class MyThread extends Thread {
String message;

MyThread ( String message ) {
this.message = message;
}

public void run() {
while ( true )
System.out.print( message );
}
}
if you get O/P:
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBB

then your OS is using Round Robin,The output is generated by an implementation of Java virtual machine for a preemptive system like UNIX OSF1, Windows 95, Windows NT, etc,

if your O/P is:
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA...........

then it using time-slicing ,the output is generated by an implementation of Java virtual machine for a non-preemptive system based on Solaris UNIX platforms


If you really enjoyed this
give feedback
thanks...... :)
 

1 comment:

Steve said...

Extending Thread just to implement the run() method is bad practice. You should implement the Runnable interface and pass instances of that into the Thread instead.