java 線程 靜態(tài)鎖,對(duì)象鎖, synchronized 是鎖方法還是鎖對(duì)象?還是鎖類?如何實(shí)現(xiàn)?? 部分代碼如下, public static Object lock=new Object() //靜態(tài)鎖,鎖類,不是鎖對(duì)象了!!所以兩個(gè)線程同時(shí) 運(yùn)行兩個(gè) TestThread 的execute( ),也可以同步!!! public void execute(){ // synchronized(lock){ for(int i=0 i<20 i++){ try { Thread.sleep(30) } catch (InterruptedException e) { // todo Auto-generated catch block e.printStackTrace() } System.out.println(Thread.currentThread().getName()+Thread.currentThread ().getName()+" "+i) } } }
上傳時(shí)間: 2017-07-15
上傳用戶:lijianyu172
// 學(xué)生管理.cpp : Defines the entry point for the application. // #include "stdafx.h" #include "resource.h" #define MAX_LOADSTRING 100 // Global Variables: HINSTANCE hInst; // current instance TCHAR szTitle[MAX_LOADSTRING]; // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text // Foward declarations of functions included in this code module: ATOM MyRegisterClass(HINSTANCE hInstance); BOOL InitInstance(HINSTANCE, int); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM); struct person { char name[10]; int ID; int cj_yw; int cj_sx; struct person* next; struct person* pro; }per; int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // todo: Place code here. MSG msg; HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_MY, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_MY); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return msg.wParam; } // // FUNCTION: MyRegisterClass() // // PURPOSE: Registers the window class. // // COMMENTS: // // This function and its usage is only necessary if you want this code // to be compatible with Win32 systems prior to the 'RegisterClassEx' // function that was added to Windows 95. It is important to call this function // so that the application will get 'well formed' small icons associated // with it. // ATOM MyRegisterClass(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_MY); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = (LPCSTR)IDC_MY; wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); return RegisterClassEx(&wcex); } // // FUNCTION: InitInstance(HANDLE, int) // // PURPOSE: Saves instance handle and creates main window // // COMMENTS: // // In this function, we save the instance handle in a global variable and // create and display the main program window. // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; hInst = hInstance; // Store instance handle in our global variable hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd) { return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; } // // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; TCHAR szHello[MAX_LOADSTRING]; LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // todo: Add any drawing code here... RECT rt; GetClientRect(hWnd, &rt); DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER); EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } // Mesage handler for about box. LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam)); return TRUE; } break; } return FALSE; }
上傳時(shí)間: 2016-12-29
上傳用戶:767483511
// 學(xué)生管理.cpp : Defines the entry point for the application. // #include "stdafx.h" #include "resource.h" #define MAX_LOADSTRING 100 // Global Variables: HINSTANCE hInst; // current instance TCHAR szTitle[MAX_LOADSTRING]; // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text // Foward declarations of functions included in this code module: ATOM MyRegisterClass(HINSTANCE hInstance); BOOL InitInstance(HINSTANCE, int); LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); LRESULT CALLBACK About(HWND, UINT, WPARAM, LPARAM); struct person { char name[10]; int ID; int cj_yw; int cj_sx; struct person* next; struct person* pro; }per; int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { // todo: Place code here. MSG msg; HACCEL hAccelTable; // Initialize global strings LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); LoadString(hInstance, IDC_MY, szWindowClass, MAX_LOADSTRING); MyRegisterClass(hInstance); // Perform application initialization: if (!InitInstance (hInstance, nCmdShow)) { return FALSE; } hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_MY); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return msg.wParam; } // // FUNCTION: MyRegisterClass() // // PURPOSE: Registers the window class. // // COMMENTS: // // This function and its usage is only necessary if you want this code // to be compatible with Win32 systems prior to the 'RegisterClassEx' // function that was added to Windows 95. It is important to call this function // so that the application will get 'well formed' small icons associated // with it. // ATOM MyRegisterClass(HINSTANCE hInstance) { WNDCLASSEX wcex; wcex.cbSize = sizeof(WNDCLASSEX); wcex.style = CS_HREDRAW | CS_VREDRAW; wcex.lpfnWndProc = (WNDPROC)WndProc; wcex.cbClsExtra = 0; wcex.cbWndExtra = 0; wcex.hInstance = hInstance; wcex.hIcon = LoadIcon(hInstance, (LPCTSTR)IDI_MY); wcex.hCursor = LoadCursor(NULL, IDC_ARROW); wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wcex.lpszMenuName = (LPCSTR)IDC_MY; wcex.lpszClassName = szWindowClass; wcex.hIconSm = LoadIcon(wcex.hInstance, (LPCTSTR)IDI_SMALL); return RegisterClassEx(&wcex); } // // FUNCTION: InitInstance(HANDLE, int) // // PURPOSE: Saves instance handle and creates main window // // COMMENTS: // // In this function, we save the instance handle in a global variable and // create and display the main program window. // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { HWND hWnd; hInst = hInstance; // Store instance handle in our global variable hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); if (!hWnd) { return FALSE; } ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); return TRUE; } // // FUNCTION: WndProc(HWND, unsigned, WORD, LONG) // // PURPOSE: Processes messages for the main window. // // WM_COMMAND - process the application menu // WM_PAINT - Paint the main window // WM_DESTROY - post a quit message and return // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; TCHAR szHello[MAX_LOADSTRING]; LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING); switch (message) { case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // Parse the menu selections: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); // todo: Add any drawing code here... RECT rt; GetClientRect(hWnd, &rt); DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER); EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; } // Mesage handler for about box. LRESULT CALLBACK About(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: return TRUE; case WM_COMMAND: if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL) { EndDialog(hDlg, LOWORD(wParam)); return TRUE; } break; } return FALSE; }
標(biāo)簽: 學(xué)生 計(jì)算器
上傳時(shí)間: 2016-12-29
上傳用戶:767483511
/*import java.util.Scanner; //主類 public class student122 { //主方法 public static void main(String[] args){ //定義7個(gè)元素的字符數(shù)組 String[] st = new String[7]; inputSt(st); //調(diào)用輸入方法 calculateSt(st); //調(diào)用計(jì)算方法 outputSt(st); //調(diào)用輸出方法 } //其他方法 //輸入方法 private static void inputSt(String st[]){ System.out.println("輸入學(xué)生的信息:"); System.out.println("學(xué)號(hào) 姓名 成績(jī)1,2,3"); //創(chuàng)建鍵盤輸入類 Scanner ss = new Scanner(System.in); for(int i=0; i<5; i++){ st[i] = ss.next(); //鍵盤輸入1個(gè)字符串 } } //計(jì)算方法 private static void calculateSt(String[] st){ int sum = 0; //總分賦初值 int ave = 0; //平均分賦初值 for(int i=2;i<5;i++) { /計(jì)總分,字符變換成整數(shù)后進(jìn)行計(jì)算 sum += Integer.parseInt(st[i]); } ave = sum/3; //計(jì)算平均分 //整數(shù)變換成字符后保存到數(shù)組里 st[5] = String.valueOf(sum); st[6] = String.valueOf(ave); } //輸出方法 private static void outputSt(String[] st){ System.out.print("學(xué)號(hào) 姓名 "); //不換行 System.out.print("成績(jī)1 成績(jī)2 成績(jī)3 "); System.out.println("總分 平均分");//換行 //輸出學(xué)生信息 for(int i=0; i<7; i++){ //按格式輸出,小于6個(gè)字符,補(bǔ)充空格 System.out.printf("%6s", st[i]); } System.out.println(); //輸出換行 } }*/ import java.util.Scanner; public class student122 { public static void main(String[] args) { // todo 自動(dòng)生成的方法存根 String[][] st = new String[3][8]; inputSt(st); calculateSt(st); outputSt(st); } //輸入方法 private static void inputSt(String st[][]) { System.out.println("輸入學(xué)生信息:"); System.out.println("班級(jí) 學(xué)號(hào) 姓名 成績(jī):數(shù)學(xué) 物理 化學(xué)"); //創(chuàng)建鍵盤輸入類 Scanner ss = new Scanner(System.in); for(int j = 0; j < 3; j++) { for(int i = 0; i < 6; i++) { st[j][i] = ss.next(); } } } //輸出方法 private static void outputSt(String st[][]) { System.out.println("序號(hào) 班級(jí) 學(xué)號(hào) 姓名 成績(jī):數(shù)學(xué) 物理 化學(xué) 總分 平均分"); //輸出學(xué)生信息 for(int j = 0; j < 3; j++) { System.out.print(j+1 + ":"); for(int i = 0; i < 8; i++) { System.out.printf("%6s", st[j][i]); } System.out.println(); } } //計(jì)算方法 private static void calculateSt(String[][] st) { int sum1 = 0; int sum2 = 0; int sum3 = 0; int ave1 = 0; int ave2 = 0; int ave3 = 0; for(int i = 3; i < 6; i++) { sum1 += Integer.parseInt(st[0][i]); } ave1 = sum1/3; for(int i = 3; i < 6; i++) { sum2 += Integer.parseInt(st[1][i]); } ave2 = sum2/3; for(int i = 3; i < 6; i++) { sum3 += Integer.parseInt(st[2][i]); } ave3 = sum3/3; st[0][6] = String.valueOf(sum1); st[1][6] = String.valueOf(sum2); st[2][6] = String.valueOf(sum3); st[0][7] = String.valueOf(ave1); st[1][7] = String.valueOf(ave2); st[2][7] = String.valueOf(ave3); } }
標(biāo)簽: java 數(shù)據(jù)庫(kù)
上傳時(shí)間: 2017-03-17
上傳用戶:simple
1.安裝好VS2010,網(wǎng)上很多人說(shuō)使用VC6.0的mscomm32.ocx控件,下載并注冊(cè),注冊(cè)過(guò)程看上去還很復(fù)雜。我是使用VS2010自帶的控件,因此沒(méi)有這些過(guò)程,只需要安裝好V52010就行了。2.建立“基于對(duì)話框”的MFC工程,命名為CommTest,應(yīng)用程序類型選擇“基于對(duì)話框”3.刪除默認(rèn)的“確定”,“取消”按鈕和靜態(tài)文本框“todo在此放置對(duì)話框控件”,添加如下對(duì)話框控件:①“打開(kāi)串口”按鈕,添加方法為從右側(cè)“工具箱”拖放一個(gè)“Button”到對(duì)話框,并在右側(cè)“屬性”卡中修改“Caption”為“打開(kāi)串口”,修改“I0”為“IDC_BUTTON_OPEN”。②“關(guān)閉串口”按鈕,添加方法為從右側(cè)“工具箱”拖放一個(gè)“Button”到對(duì)話框,并在右側(cè)“屬性”卡中修改“Caption”為“關(guān)閉串口”,修改“ID”為“IDC_BUTTON_CLOSE”。③“發(fā)送”按鈕,添加方法為從右側(cè)“工具箱”拖放一個(gè)“Button”到對(duì)話框,并在右側(cè)“屬性”卡中修改“Caption”為“發(fā)送”,修改“ID”為“IDC_BUTTON_SEND”。④“發(fā)送編輯框”。⑤“接受編輯框”
上傳時(shí)間: 2022-06-30
上傳用戶:shjgzh
AppleMusic - B站首頁(yè)界面設(shè)計(jì):附詳細(xì)教程 - cnode社區(qū)版 - dribbble - FlexLayout布局 - gank - HIapp - IT-EBOOK - leantodu - LOL戰(zhàn)績(jī)查詢 - movecss效果 - Railay:整體框架 - redux綁定 - TCP,IP長(zhǎng)連接 - todo list - v2ex - 一個(gè)(仿) - 一元奪寶主頁(yè)設(shè)計(jì) - 萬(wàn)年歷 - 下拉刷新,tab切換 - 東航訂機(jī)票 - 事項(xiàng)助手 - 二維碼生成器 - 云筆記 - 五十音圖 - 五險(xiǎn)一金計(jì)算 - 人臉檢測(cè) - 今日頭條 - 仿微信DEMO - 仿找事吧 - 仿網(wǎng)易云音樂(lè) - 會(huì)議精靈 - 你畫(huà)我猜 - 側(cè)滑布局 - 健康菜譜 - 全屏動(dòng)畫(huà)滾動(dòng) - 內(nèi)容說(shuō)明.txt 527B 分答小程序 - 創(chuàng)客+實(shí)現(xiàn)大量功能,推薦研究 - 剪刀石頭布 - 醫(yī)藥網(wǎng) - 卡卡汽車 獲取用戶 設(shè)備信息 - 同樂(lè)居商城:購(gòu)物車合算 - 商城 - 圖書(shū)管理系統(tǒng) - 圖文信息;歡迎頁(yè)面,音樂(lè)控制 - 圖片自適應(yīng) ,富文本解析 - 圓形菜單 - 城市切換 - 備忘錄 - 外賣:實(shí)現(xiàn)類似錨點(diǎn)功能 - 大轉(zhuǎn)盤 - 天氣預(yù)報(bào) - 媽媽課堂 - 家居電商 - 富文本解析,折線圖,MD5,bluebird - 小游戲-別踩白塊 - 小熊的日記 - 小程序地圖定位 - 小程序完整demo:飛翔的小鳥(niǎo):canvas實(shí)現(xiàn),java后端(適用1221) - 小程序官方Demo - 小程序版2048 - 小程序統(tǒng)計(jì)[只需一行代碼].url 132B 小程序頁(yè)面生成器 - 康愛(ài)多微商城:學(xué)習(xí)界面設(shè)計(jì) - 微票 - 我廚 tab 界面設(shè)計(jì) - 手勢(shì)解鎖 - 掘金首頁(yè)信息流 - 搖一搖換文章 - 教務(wù)系統(tǒng) - 新浪讀書(shū) - 新聞客戶端 - 易打卡 表單設(shè)計(jì) - 星巴克中國(guó) - 智能機(jī)器人 - 機(jī)器人兔兔 - 極客學(xué)院 - 果庫(kù) - 查拼音 - 校內(nèi)新聞大圖 - 框架 - 步步高字典 - 水滸傳 - 治療師 - 涂鴉 - 滑動(dòng)選項(xiàng)卡 - 滴滴公交-查公交 - 瀑布流布局 - 用戶反饋組件 - 電商-拼團(tuán) 倒計(jì)時(shí) - 電影推薦 - 電影日歷 - 畫(huà)布:時(shí)鐘 - 番茄時(shí)鐘 - 百度小說(shuō) - 相冊(cè);處理用戶信息 - 省市選擇控件 - 知乎 - 知乎日?qǐng)?bào) - 知乎日?qǐng)?bào)1 - 科學(xué)計(jì)算器 - 移動(dòng)小商城:基于node,包含前后臺(tái) - 移動(dòng)端商城 - 簡(jiǎn)易計(jì)算器 - 網(wǎng)易云課堂 - 騰訊云小程序一站式解決方案 - 自定義tabbar - 芒果TV - 語(yǔ)音跟讀 - 豆瓣圖書(shū) - 豆瓣電影 - 貨幣匯率 - 購(gòu)物車 - 跑步 地理位置 計(jì)時(shí)器 - 身份證查詢 - 車源寶 - 輪播圖+菜單 - 輪播圖變換 - 辯論倒計(jì)時(shí) - 重郵 - 題庫(kù):選擇選項(xiàng),切換至下一題 - 首字母排序選擇 - 高仿蘋果計(jì)算器
上傳時(shí)間: 2013-06-12
上傳用戶:eeworm
蟲(chóng)蟲(chóng)下載站版權(quán)所有 京ICP備2021023401號(hào)-1