public class InterruptTest { public static void main(String[] args) {// TODO Auto-generated method stub ThreadInterrupt th = new ThreadInterrupt("Thread");th.start();try {Thread.sleep(2000);th.interrupt(); //2초 뒤 인터럽트} catch (InterruptedException e) {}}} class ThreadInterrupt extends Thread {ThreadInterrupt(String str) {super(str);} public void run() {try {for (int i = 0; i < 10; i++) {Thread.sl..
public class DaemonThread extends Thread { public void run() {try {System.out.println("데몬 스레드 시작");Thread.sleep(100); //슬립하는 동안 메인이 죽으면//다음 코드가 실행되지 않고 스레드가 죽는다.System.out.println("데몬 스레드 종료");} catch (Exception e) {e.printStackTrace();}} public static void main(String[] args) {// TODO Auto-generated method stubDaemonThread thread = new DaemonThread();thread.setDaemon(true);//join은 스레드가 끝나기를 메인이..
class Account {private int total = 0; synchronized void deposit() {total = total + 1000;} int gettotal() {return total;}} class Customer extends Thread {Account same_a; Customer(Account a, String s) {same_a = a;setName(s);} public void run() {for (int i = 0; i = 500000)break; // 종료 시 5개의 스레드 중..
class Account {int balance = 1000; public void withdraw(int money) {if (balance >= money) {try {Thread.sleep(1000);} catch (Exception e) {}balance -= money;}}} class Bank extends Thread {static Account ac = new Account(); public Bank() {}; public Bank(String name) {super(name);}; public void run() {while (true) {//동기화를 하면 먼저 임계구역에 접근한 스레드가 구역을 점령한다.synchronized (ac) {int money = (int) (Math.rand..
public class DataModelTest { public static void main(String[] args) {// TODO Auto-generated method stub String rows[][] = { { "수곡동", "야구" }, { "모충동", "족구" }, { "개신동", "축구" } };String headers[] = { "이름", "종목" };String sports[] = { "야구", "축구", "족구", "기타" }; JComboBox comboBox = new JComboBox(sports);comboBox.setMaximumRowCount(4); TableCellEditor editor = new DefaultCellEditor(comboBox);JFrame fra..
public class JTableTest extends JFrame { JTableTest() {super("JTable Test");String title[] = { "번호", "이름", "나이" };String data[][] = { { "1", "김 구", "40" }, { "2", "강감찬", "42" },{ "3", "이순신", "41" } };JTable table = new JTable(data,title);//테이블객체 생성, 데이터와 타이틀을 인자로 가짐JScrollPane sp = new JScrollPane(table); //스크롤페인 붙임getContentPane().add(sp, BorderLayout.CENTER);//setSize(300,150);setVisible(true)..
public class BoxLayoutTest extends JFrame { public BoxLayoutTest() {super("Box Layout Test example");JRadioButton r1, r2; setLayout(new BorderLayout());Box left = Box.createVerticalBox();left.add(Box.createVerticalStrut(30)); ButtonGroup radioGroup = new ButtonGroup();radioGroup.add(r1 = new JRadioButton("야구"));left.add(r1); left.add(Box.createVerticalStrut(30));radioGroup.add(r2 = new JRadioBut..
public class ComboTest extends JFrame {JList jl;JComboBox com;String name[] = { "수곡동", "도곡동", "용암동", "분평동", "개신동" };String count[] = { "1", "2", "3", "4", "5" }; public ComboTest() {super("JComponent practice");Container c = getContentPane(); //Returns the contentPane object for this frame.c.setLayout(new FlowLayout()); //컨테이너의 레이아웃 설정 com = new JComboBox(name); //콤보박스에 name 붙임JScrollPane s = ne..
- Total
- Today
- Yesterday
- 데이터베이스
- 파이썬
- 충북대
- 소켓
- CSS
- 자바스크립트
- SVN
- HTML
- SQL
- 게임
- db
- 청주
- 알고리즘
- 아두이노
- 이론
- JQuery
- 클래스
- 배열
- 자바
- ERP
- 프로젝트
- jsp
- 잡담
- 안드로이드
- 졸업작품
- 오라클
- 메모장
- 정보
- 정렬
- 도전과제
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |