/* # 프로그램 순서 사용자로부터 시간 간격을 입력 받는다. 입력 받은 시간 간격마다 fork()함수로 프로세스를 복제한다. 복제된 자식 프로세스는 execl()함수를 이용하여 date명령을 수행하는 자식 프로세스를 생성하고 종료된다. 입력 받은 시간간격으로 현재 시간과 날짜를 반복 출력한다. # 요구사항 프로그램을 작성 후 Makefile을 만들어서 컴파일 한다.
# 부연설명 fork는 자신과 동일한 프로세스만 생성 가능하지만, execl은 자신과 다른 프로세스를 생성 가능하다. fork는 새로운 프로세스를 생성하더라도 종료되지 않고 자식 프로세스와 동시에 수행되지만, execl은 새로운 프로세스를 생성하면 자신은 종료되어야 한다. fork로 자식 프로세스를 생성한 후 자식 프로세스 가 execl로 새로운 프로세스를 생성한 후 종료됨.(fork의 장점과 execl의 장점을 동시에 취함) */
사용자로부터 프로세스 생성 개수를 입력 받는다. 입력 받은 개수만큼 프로세스(“sleep 10000” 사용)를 생성한다. (생성시 백그라운드 설정) 생성된 프로세스 목록을 보여준다. (ps 명령어에 옵션 사용) 사용자로부터 프로세스 아이디(PID)를 입력 받는다. 입력 받은 프로세스를 삭제하고, 남은 프로세스 목록을 보여주며 프로그램을 종료한다.
# 요구사항
프로그램을 작성 후 Makefile을 만들어서 컴파일 한다. 시스템 프로세스를 비롯한 다른 것들을 삭제하지 않도록 한다.
Find Me Here Speak To Me I want to feel you I need to
hear you You are the light That's leading me To the place where I find
peace again.
You are the strength, that keeps me walking. You are the
hope, that keeps me trusting. You are the light to my soul. You are my
purpose...you're everything.
How can I stand here with you and not be
moved by you? Would you tell me how could it be any better than
this?
You calm the storms, and you give me rest. You hold me in your
hands, you won't let me fall. You still my heart, and you take my breath
away. Would you take me in? Take me deeper now?
How can I stand here
with you and not be moved by you? Would you tell me how could it be any
better than this? And how can I stand here with you and not be moved by
you? Would you tell me how could it be any better than this?
Cause
you're all I want, You're all I need You're everything,everything You're
all I want your all I need You're everything, everything. You're all I
want you're all I need. You're everything, everything You're all I want
you're all I need, you're everything, everything.
And How can I stand
here with you and not be moved by you? Would you tell me how could it be any
better than this? How can I stand here with you and not be moved by
you? Would you tell me how could it be any better than
this?
[background] How can I stand here with you and not be moved by
you? Would you tell me how could it be any better than this?
Would you
tell me how could it be any better than this?
// 키들로만 구성된 집합을 추출 Set keySet = ht.keySet(); Iterator iter = keySet.iterator();
// 다음키가 있는지 검사합니다. while(iter.hasNext() == true){
// 키를 순차적으로 읽어 옵니다. String key = (String)iter.next();
// 키에 해당하는 값을 추출합니다. String str = (String)ht.get(key); System.out.println(key + " - " + str); } } }
[03] Generics
- 객체를 저장하는 기술인 Collection Framework의 단점을 개선한 기능입니다. 기존의 1.4이하에서는 Vector등에 들어오는 객체의 타입을 Design Time에 확인이 안되 에러를 잡기 힘들었으나 1.5부터는 개발자가 개발시에 이클립스로부터 에러 상황을 바로 확인할 수 있습니다.
- Class ArrayList<E>에서 'E'가 있는 곳에는 ArrayList를 선언하고 생성할 때 사용할 실제타입이 들어갑니다.
- E는 Element(원소)를 말하며, new ArrayList<String>() 이면 'E'는 'String' 클래스를 가르키며, < > 안의 String은 유형 매개 변수 (type parameter)이다. 따라서 boolean add(Object o) 메소드는 boolean add(String o) 가 된다.
- 'E'는 ArrayList의 인스턴스를 만들때 < > 안에 넣는 타입을 말합니다.
- 'E'는 컬렉션에 저장하고 컬렉션에서 리턴할 원소의 타입을 가르킵니다.
※ Generics 관련 예제
1. 1.4이하의 패턴
>>>>> Old14.java
import java.util.Vector;
public class Old14 {
public static void main(String[] args) { // 객체 10개를 저장할 수 있는 list 객체 변수 선언 Vector list = new Vector(1000);
list.add(new Integer(10)); //Integer 추가 list.add(new Integer(50)); //Integer 추가 list.add("List Test"); //String 추가, ERROR
public static void main(String[] args) { //선언되는 list는 Integer 클래스 타입만 저장할 수 있습니다. Vector<Integer> list = new Vector<Integer>(10); list.add(new Integer(10));
//ERROR 강제 발생 부분, Integer 타입만 가능, //Design Time에서 발견됩니다. list.add("List Test");
Iterator i = list.iterator(); Integer su = (Integer)i.next(); System.out.println("su=" + su);
su = (Integer)i.next(); System.out.println("su=" + su); } }