想问下面这样的代码中thread1.a(); thread2.b();在主程序中能同步吗!?
class thread1 {
synchronized void a(){}
void run(){..}
.......
}
class thread2{
synchronized void b(){}
void run(){..}
.........
}
class ss{
public static void main(String[] args){
thread1 th1 = new thread1();
thread2 th2 = new thread2();
th1.start();
th2.start();
......
...}
}
class thread1 {
synchronized void a(){}
void run(){..}
.......
}
class thread2{
synchronized void b(){}
void run(){..}
.........
}
class ss{
public static void main(String[] args){
thread1 th1 = new thread1();
thread2 th2 = new thread2();
th1.start();
th2.start();
......
...}
}
解决方案 »
- ButtonGroup的添加问题,小菜求教!
- 简单SQL语句问题
- 求树型结构示例代码
- JAVA中的main遇到的问题,急!!!!
- 高手帮忙,如何读取一个文件夹下的所有的文件名并输出到文件文件或者EXCEL文件?
- jar包里放的策略文件,程序找不到?
- 一个包中的类调用另一个包中的类的出现的错误(新手问题)
- jbulider中怎么生成子目录包
- java推荐的日期格式转换方法是什么?
- SYBASE11.9通过JDBC来链接据库时,我做的conn不支持ROLLBACK(来者有分)
- 困扰了我三天的java.lang.OutOfMemoryError: Java heap space问题,大家给点主意!!
- 下步我该怎么学习
还有你的THREAD1和2好想错了
比如:
static class LogConsumer implements Runnable
{
public void run()
{
try
{
startConsumer();
} catch (InterruptedException e)
{
throw CommonUtils.toRuntimeException(e);
} catch (LoggerException e)
{
throw CommonUtils.toRuntimeException(e);
}
}
private void startConsumer() throws LoggerException, InterruptedException
{
for (;;)
{
SQLInfo info = (SQLInfo) channel.take();
for (int i = 0, n = dbListeners.length; i < n; i++)
{
dbListeners[i].logSql(info);
} }
}
}
在DBLogger类中,从www.cownew.com下载。
本人欲成立一个java开源组织,有兴趣的朋友可以加入,开源组织设立两个区域,一个区域是实际开发区,主要是实际的项目的开发;一个区域是后备力量培养区,主要为有热情加入开源组织、有一定的开发经验的朋友准备,这个区域将由专门的专家指导,提高开发能力。我们将积极的联系开源项目商业化,让项目组成员得到适当的回报。
有意者联系:qq:57077490 qq群:20392347