二、项目源码
1、结构图

2、StaticC1.java
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
32
33
34
35
36
37
38
39
40
41
42
43
|
package
com.gossip;
public
class
StaticC1 {
private
String userName;
private
String age;
private
String birthDate;
public
String getUserName() {
return
userName;
}
public
void
setUserName(String userName) {
this
.userName = userName;
}
public
String getAge() {
return
age;
}
public
void
setAge(String age) {
this
.age = age;
}
public
String getBirthDate() {
return
birthDate;
}
public
void
setBirthDate(String birthDate) {
this
.birthDate = birthDate;
}
@Override
public
String toString() {
return
"StaticC1{"
+
"userName='"
+ userName + '\
''
+
", age='"
+ age + '\
''
+
", birthDate='"
+ birthDate + '\
''
+
'}'
;
}
}
|
3、Provider.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package
com.gossip;
import
java.util.Date;
public
class
Provider {
private
static
StaticC1 s1;
public
static
void
main(String[] args) {
System.out.println(
"当前线程:"
+ Thread.currentThread().getName());
System.out.println(
"当前时间:"
+
new
Date());
System.out.println(
"主线程休眠5分钟"
);
s1 =
new
StaticC1();
System.out.println(
"StaticC1:"
+ s1.toString());
try
{
//休眠5分钟
Thread.sleep(
300000
);
}
catch
(InterruptedException e) {
e.printStackTrace();
}
}
}
|
三、打包过程
1、File-->Project Structure
这里选择Empty
2、Build打包
jar包生成目录:simplecode\out\artifacts\simplecode\simplecode.jar
四、Linux运行jar包
java -jar simplecode.jar