Professional Documents
Culture Documents
Ministry of Education
University of Bisha
College of Computing and Information Technology
LAB-2
Verify the software components
a. System files
b. Log files
c. Check for a change
d. Check for modification
e. Check for blemishes
f. Check for add-ons
......................................................................................................................................
public class GetCurrentThread {
public static void main(String[] args) {
Thread currentThread = Thread.currentThread();
System.out.println(currentThread);
}
}
......................................................................................................................................
/*Get Thread State
class GetThreadState extends Thread {
}
}
......................................................................................................................................
/*
Joining Threads
The join() method allows one thread to wait for the
completion of another.
If t is a Thread object whose thread is currently
executing,
t.join() causes the current thread to pause execution
until t's thread terminates.
Source: (JoiningThreads.java)
*/
class JoiningThreads extends Thread {
int sleep;
JoiningThreads(int sleep) {
this.sleep = sleep;
}
public void run() {
System.out.println("Begin: " + this.getName());
try {
Thread.sleep (sleep);
} catch (InterruptedException e) {
}
System.out.println("End: " + this.getName());
}
public static void main (String args[]) throws
InterruptedException {
JoiningThreads t1 = new JoiningThreads(6000);
JoiningThreads t2 = new JoiningThreads(2000);
JoiningThreads t3 = new JoiningThreads(3000);
t1.start();
t2.start();
t3.start();
t1.join();
t2.join();
t3.join();
System.out.println("Finished");
}
}
..........................................................................................................
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class RunTimeExample {
public static void main(String[] args) {
try {
// print a message
System.out.println("Executing notepad.exe");
// create a process and execute notepad.exe
Process process = Runtime.getRuntime().exec("notepad.exe");
// print another message
System.out.println("Notepad should now open.");
Runtime.getRuntime().exec("cmd /c start cmd.exe /K \"dir \"");
Runtime.getRuntime().exec("cmd /c start c:/Users/adobegc.log /K \" \"");
System.out.println("Notepad should now open.");
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
.........................................................................................................
import java.io.*;
import java.util.*;
class TestStack
{
// Pushing element on the top of the stack
static void stack_push(Stack<Integer> stack)
{
for(int i = 0; i < 5; i++)
{
stack.push(i);
}
}
// Popping element from the top of the stack
static void stack_pop(Stack<Integer> stack)
{
System.out.println("Pop Operation:");
if(pos == -1)
System.out.println("Element not found");
else
System.out.println("Element is found at position: " + pos);
}
stack_push(stack);
stack_pop(stack);
stack_push(stack);
stack_peek(stack);
stack_search(stack, 2);
stack_search(stack, 6);
}
}
/*
Output:
Pop Operation:
4
3
2
1
0
Element on stack top: 4
Element is found at position: 3
Element not found
*/