2011-05-11 28 views
-2

我要问你一件事我做这样的..LinkedBlockQueue不能通过必看

LinkedBlockingQueue<Whatch_Directory> queue 
    = new LinkedBlockingQueue<classes.Watchable.Whatch_Directory>(); 
queue.put(classes.Watchable.Whatch_Directory.create_watchable("dir")); 

,但一切从classes.Watchable等下来,这是与悦目课堂上的一切顺着他的功能没有显示,仍然只有监视器正在运行。

+0

什么?这非常混乱。 – I82Much 2011-05-11 15:56:06

+0

什么是Whatch_Directory?我的猜测是你正试图使用​​一个不公开的类,或者像WatchDirectory或Watch_Directory这样的其他类。我不知道为什么你会在任何情况下通过队列中的Watchable。 – 2011-05-11 16:03:17

回答

0

如果我明白你在问什么,你正在其他地方创建一个Whatch_Directory类,试图制作LinkedBlockingQueue这样的东西,并使用工厂方法create_watchable()创建一个。

如果是这样,看起来Whatch_Directory扩展了Watchable接口(根据您的其他问题)。看来你的代码应该成为更多的东西一样:

class Whatch_Directory implements Watchable { 
    public static Watchable create_watchable(String s) { 
     // Your definition goes here 
    } 
} 

LinkedBlockingQueue<Whatch_Directory> queue = 
    new LinkedBlockingQueue<Whatch_Directory>(); 
queue.put(Whatch_Directory.create_watchable("dir"); 

你的意图的一些更多的解释将是有益的,但这里有一些东西,我建议你检查根据我的理解:

  1. 制作确定create_watchable()返回正确的类型。它需要根据您的代码返回Whatch_Directory类型的东西。

  2. 确保create_watchable()由于某种原因没有返回null

  3. 确保create_watchable()不引发异常。

+0

谢谢:)我会试试看,那个可怕的课只是让我哭泣.. – user639285 2011-05-11 17:15:30