import java.io.*;
import java.util.*;
public class QueueImplement{
LinkedList<Integer> list;
String str;
int num;
public static void main(String[] args){
QueueImplement q = new QueueImplement();
}
public QueueImplement(){
try{
list = new LinkedList<Integer>();
InputStreamReader ir = new InputStreamReader(System.in);
BufferedReader bf = new BufferedReader(ir);
System.out.println("Enter number of elements : ");
str = bf.readLine();
if((num = Integer.parseInt(str)) == 0){
System.out.println("You have entered either zero/null.");
System.exit(0);
}
else{
System.out.println("Enter elements : ");
for(int i = 0; i < num; i++){
str = bf.readLine();
int n = Integer.parseInt(str);
list.add(n);
}
}
System.out.println("First element :" + list.removeFirst());
System.out.println("Last element :" + list.removeLast());
System.out.println("Rest elements in the list :");
while(!list.isEmpty()){
System.out.print(list.remove() + "\t");
}
}
catch(IOException e){
System.out.println(e.getMessage() + " is not a legal entry.");
System.exit(0);
}
}
}
/*
* MLFQ.java
*
* Created on December 3, 2008, 4:13 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/ import java.util.*; //ArrayList,Collection,LinkedList,List,Queue
import javax.swing.*; /**
* @author Ahmed Zaki
*/
class Process {
private String id_ ; // id of each process
private int arrival_time_ ;
private int burst_time_ ;
public Process(){
}
} public class MLFQ {
/** Creates a new instance of MLFQ */
public MLFQ() {
}
public static int NumOfProcess = 0;
private LinkedList<Process> Q0 = new LinkedList(); //Ready Queue with Quantium = 8 unit
private LinkedList<Process> Q1 = new LinkedList(); //Queue 1 With RR Quanum = 16 unit
private LinkedList<Process> Q2 = new LinkedList(); //Queue 2 With FCFS Paiorty
private List Process = new ArrayList();
private int Average_turnaround_time = 0;
private int Maximum_turnaround_time = 0;
private int Average_wait_time = 0;
private int Maximum_wait_time = 0;
private int CPU_utilization = 0;
private int Throughput = 0; // number of jobs process per hours
private int processes = 0;
public void addProcess() {
if ( NumOfProcess < 2 ){
JOptionPane.showMessageDialog(null, "U Must Enter At least Two Process \n We Must Exit the program Now");
System.exit(0);
}else{
for(int i=0 ; i<=NumOfProcess; i++ ){
// process ID
String id = JOptionPane.showInputDialog("Enter The Process ID !!!");
// process Arrival Time
String arr_time = JOptionPane.showInputDialog("Enter The Process Arrival Time !!");
int p_arr_time = Integer.parseInt(arr_time);
// process Burst Time
String bur_time = JOptionPane.showInputDialog("Enter The Process Burst Time !!!");
int p_bur_time = Integer.parseInt(bur_time);
}
}
}
public void removeProcess() {
}
public void quantumExpired() {
//queue.remove(p);
//queue.add(p);
//blockedOnQuantumExpiration++;
} public void addProcessTrace(Process p) {
// TODO Auto-generated method stub
} public void addProcessTraces(Collection<Process> list) {
// TODO Auto-generated method stub
}
public void blockedOnIO(Process p) {
// TODO Auto-generated method stub
} public void blockedOnPageFault(Process p) {
// TODO Auto-generated method stub
} public void blockedOnSleep(Process p) {
// TODO Auto-generated method stub
} public Process getCurrentProcess() {
// TODO Auto-generated method stub
return null;
} public boolean hasAliveProcess() {
// TODO Auto-generated method stub
return false;
} public boolean hasRunnableProcess() {
// TODO Auto-generated method stub
return false;
} public void quantumExpired(Process p) {
// TODO Auto-generated method stub
} public void removeProcess(Process p) {
// TODO Auto-generated method stub
} public void report() {
// TODO Auto-generated method stub
} public void unblocked(Process p) {
// TODO Auto-generated method stub
}
public static void main(String[] args){
MLFQ MultiFeed = new MLFQ();
String input = JOptionPane.showInputDialog("Enter The Number Of Process Plz");
NumOfProcess = Integer.parseInt(input);
MultiFeed.addProcess();
while(true){
String [] operations= { "Simulate and View the result "," Quit "};
int choice_=JOptionPane.showOptionDialog(null,"Select Ur Choice","Choice Menu",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE,null,operations,operations[0]);
switch(choice_){
case 0:
MultiFeed.addProcess();
JOptionPane.showMessageDialog(null, " Please Wait While Compress Complete ... ");
break;
case 1:
JOptionPane.showMessageDialog(null, " Bye Bye ");
System.exit( 0 );
}
} } } /*
* MLFQ.java
*
* Created on December 3, 2008, 4:13 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/ import java.util.*; //ArrayList,Collection,LinkedList,List,Queue
import javax.swing.*; /**
* @author Ahmed Zaki
*/
class Process {
private String id_ ; // id of each process
private int arrival_time_ ;
private int burst_time_ ;
public Process(){
}
} public class MLFQ {
/** Creates a new instance of MLFQ */
public MLFQ() {
}
public static int NumOfProcess = 0;
private LinkedList<Process> Q0 = new LinkedList(); //Ready Queue with Quantium = 8 unit
private LinkedList<Process> Q1 = new LinkedList(); //Queue 1 With RR Quanum = 16 unit
private LinkedList<Process> Q2 = new LinkedList(); //Queue 2 With FCFS Paiorty
private List Process = new ArrayList();
private int Average_turnaround_time = 0;
private int Maximum_turnaround_time = 0;
private int Average_wait_time = 0;
private int Maximum_wait_time = 0;
private int CPU_utilization = 0;
private int Throughput = 0; // number of jobs process per hours
private int processes = 0;
public void addProcess() {
if ( NumOfProcess < 2 ){
JOptionPane.showMessageDialog(null, "U Must Enter At least Two Process \n We Must Exit the program Now");
System.exit(0);
}else{
for(int i=0 ; i<=NumOfProcess; i++ ){
// process ID
String id = JOptionPane.showInputDialog("Enter The Process ID !!!");
// process Arrival Time
String arr_time = JOptionPane.showInputDialog("Enter The Process Arrival Time !!");
int p_arr_time = Integer.parseInt(arr_time);
// process Burst Time
String bur_time = JOptionPane.showInputDialog("Enter The Process Burst Time !!!");
int p_bur_time = Integer.parseInt(bur_time);
}
}
}
public void removeProcess() {
}
public void quantumExpired() {
//queue.remove(p);
//queue.add(p);
//blockedOnQuantumExpiration++;
} public void addProcessTrace(Process p) {
// TODO Auto-generated method stub
} public void addProcessTraces(Collection<Process> list) {
// TODO Auto-generated method stub
}
public void blockedOnIO(Process p) {
// TODO Auto-generated method stub
} public void blockedOnPageFault(Process p) {
// TODO Auto-generated method stub
} public void blockedOnSleep(Process p) {
// TODO Auto-generated method stub
} public Process getCurrentProcess() {
// TODO Auto-generated method stub
return null;
} public boolean hasAliveProcess() {
// TODO Auto-generated method stub
return false;
} public boolean hasRunnableProcess() {
// TODO Auto-generated method stub
return false;
} public void quantumExpired(Process p) {
// TODO Auto-generated method stub
} public void removeProcess(Process p) {
// TODO Auto-generated method stub
} public void report() {
// TODO Auto-generated method stub
} public void unblocked(Process p) {
// TODO Auto-generated method stub
}
public static void main(String[] args){
MLFQ MultiFeed = new MLFQ();
String input = JOptionPane.showInputDialog("Enter The Number Of Process Plz");
NumOfProcess = Integer.parseInt(input);
MultiFeed.addProcess();
while(true){
String [] operations= { "Simulate and View the result "," Quit "};
int choice_=JOptionPane.showOptionDialog(null,"Select Ur Choice","Choice Menu",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE,null,operations,operations[0]);
switch(choice_){
case 0:
MultiFeed.addProcess();
JOptionPane.showMessageDialog(null, " Please Wait While Compress Complete ... ");
break;
case 1:
JOptionPane.showMessageDialog(null, " Bye Bye ");
System.exit( 0 );
}
} } } /*
* MLFQ.java
*
* Created on December 3, 2008, 4:13 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/ import java.util.*; //ArrayList,Collection,LinkedList,List,Queue
import javax.swing.*; /**
* @author Ahmed Zaki
*/
class Process {
private String id_ ; // id of each process
private int arrival_time_ ;
private int burst_time_ ;
public Process(){
}
} public class MLFQ {
/** Creates a new instance of MLFQ */
public MLFQ() {
}
public static int NumOfProcess = 0;
private LinkedList<Process> Q0 = new LinkedList(); //Ready Queue with Quantium = 8 unit
private LinkedList<Process> Q1 = new LinkedList(); //Queue 1 With RR Quanum = 16 unit
private LinkedList<Process> Q2 = new LinkedList(); //Queue 2 With FCFS Paiorty
private List Process = new ArrayList();
private int Average_turnaround_time = 0;
private int Maximum_turnaround_time = 0;
private int Average_wait_time = 0;
private int Maximum_wait_time = 0;
private int CPU_utilization = 0;
private int Throughput = 0; // number of jobs process per hours
private int processes = 0;
public void addProcess() {
if ( NumOfProcess < 2 ){
JOptionPane.showMessageDialog(null, "U Must Enter At least Two Process \n We Must Exit the program Now");
System.exit(0);
}else{
for(int i=0 ; i<=NumOfProcess; i++ ){
// process ID
String id = JOptionPane.showInputDialog("Enter The Process ID !!!");
// process Arrival Time
String arr_time = JOptionPane.showInputDialog("Enter The Process Arrival Time !!");
int p_arr_time = Integer.parseInt(arr_time);
// process Burst Time
String bur_time = JOptionPane.showInputDialog("Enter The Process Burst Time !!!");
int p_bur_time = Integer.parseInt(bur_time);
}
}
}
public void removeProcess() {
}
public void quantumExpired() {
//queue.remove(p);
//queue.add(p);
//blockedOnQuantumExpiration++;
} public void addProcessTrace(Process p) {
// TODO Auto-generated method stub
} public void addProcessTraces(Collection<Process> list) {
// TODO Auto-generated method stub
}
public void blockedOnIO(Process p) {
// TODO Auto-generated method stub
} public void blockedOnPageFault(Process p) {
// TODO Auto-generated method stub
} public void blockedOnSleep(Process p) {
// TODO Auto-generated method stub
} public Process getCurrentProcess() {
// TODO Auto-generated method stub
return null;
} public boolean hasAliveProcess() {
// TODO Auto-generated method stub
return false;
} public boolean hasRunnableProcess() {
// TODO Auto-generated method stub
return false;
} public void quantumExpired(Process p) {
// TODO Auto-generated method stub
} public void removeProcess(Process p) {
// TODO Auto-generated method stub
} public void report() {
// TODO Auto-generated method stub
} public void unblocked(Process p) {
// TODO Auto-generated method stub
}
public static void main(String[] args){
MLFQ MultiFeed = new MLFQ();
String input = JOptionPane.showInputDialog("Enter The Number Of Process Plz");
NumOfProcess = Integer.parseInt(input);
MultiFeed.addProcess();
while(true){
String [] operations= { "Simulate and View the result "," Quit "};
int choice_=JOptionPane.showOptionDialog(null,"Select Ur Choice","Choice Menu",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE,null,operations,operations[0]);
switch(choice_){
case 0:
MultiFeed.addProcess();
JOptionPane.showMessageDialog(null, " Please Wait While Compress Complete ... ");
break;
case 1:
JOptionPane.showMessageDialog(null, " Bye Bye ");
System.exit( 0 );
}
} } }
Add weights to the elements of the queue and use an algorithm to sort the queue every time an element is added.
The java interpreter or JVM (Java Virtual Machine) is not able to execute the java source code for a program. The java source code first needs to be compiled into bytecode that can be processed by JVM. Producing bytecode make the program platform independent as each platform has its own JVM. It is also possible to directly write bytecode, bypassing the need to compile, but that would be tedious job and also not good for security purpose as the compiler checks for various errors in a program.
If the software is open source then generally they will provide the code in a separate link. I don't think it is possible to reverse-engineer the code of a program.
A Program in Java that spawns multiple threads is called a multithreaded program in Java.
AnswerA Java Drive-By is a Java Applet that is coded in Java and is put on a website. Once you click "Run" on the pop-up, it will download a program off the internet. This program can be a virus or even a simple downloader. If you'd like to get the source code or wanna know more information about a Java Drive-By, use Google.
A 'queue' is a particular kind of data structure that Java is capable of working with. There are no products called "Java Queue" and is thus not something one can download.
Add weights to the elements of the queue and use an algorithm to sort the queue every time an element is added.
A Java Thread is a thread of execution in a Java Program. A Java Virtual Machine can have a single application running multiple threads, which is known as concurrency. Threads are what make the program run. Each thread has a different priority, and when the machine queue fills up, the threads are executed in the order of their priority.
If you want to compile a java program the name of that source code must end with extension .java
If someone talks about "Java code," then they're are most likely referring to the source code of a Java program.
Knowing Java does not allow you to hack a Java program because the source code is not available to hackers. Also, a program interprets the bit-code before you see it, so even with a decompiler, hacking the program will not be possible.
The java interpreter or JVM (Java Virtual Machine) is not able to execute the java source code for a program. The java source code first needs to be compiled into bytecode that can be processed by JVM. Producing bytecode make the program platform independent as each platform has its own JVM. It is also possible to directly write bytecode, bypassing the need to compile, but that would be tedious job and also not good for security purpose as the compiler checks for various errors in a program.
A java compiler takes Java source code and turns it into Java bytecode, which can then be run by the java virtual machine.Using JIT means that the java code will be compiled and executed at the time that you run the program, which will slow down the program because it has to compile the code at the same time that it runs.
If the software is open source then generally they will provide the code in a separate link. I don't think it is possible to reverse-engineer the code of a program.
There are programming languages in which the source file is read and interpreted directly, but those are usually slower than when the program is compiled, to an EXE, or as in Java, for a virtual machine.
To edit Java source code you can use any text editor. In order to compile a Java source file to Java bytecode you need the Java Development Kit (JDK). The program which does this is called "javac" and can produce .class files which can be used by the Java Runtime Environment (JRE) to execute.
A Program in Java that spawns multiple threads is called a multithreaded program in Java.