Java队列实现(Java Queue Implementation)

我是Java新手并尝试使用:

public static ArrayBlockingQueue<String> qu=new ArrayBlockingQueue<>(900);
...
qu.enqueue(MyString);

要么

public static Queue<String> qu=new Queue<>(900);
...
qu.enqueue(MyString);

队列尖叫,声称它只是一个界面。 ArrayBlockingQueue不接受入队。 我觉得我犯了一些基本错误。 我的问题是:每次使用它时,我是否必须编写自己的Queue来实现接口,或者是否有就绪函数? 如果是的话,我做错了什么? 我的第二个问题是:什么是标准队列大小? 根据我读过的规格,我认为它必须是我可能使用的最大值,但对于小型应用来说,900不是一个很大的空间接受者吗?


I am new to Java and trying to use:

public static ArrayBlockingQueue<String> qu=new ArrayBlockingQueue<>(900);
...
qu.enqueue(MyString);

or

public static Queue<String> qu=new Queue<>(900);
...
qu.enqueue(MyString);

Queue screams,claiming it's only an interface. ArrayBlockingQueue does not accept enqueue. I feel I'm making some basic mistake. My question is: do I have to write my own Queue implementing the interface every time I use it or is there a ready function? If yes, what am I doing wrong? My second question is: what is a standard queue size? From the specifications I've read I assumed it must be the maximum I may use but isn't 900 a bit big space-taker for a small application?


原文:https://stackoverflow.com/questions/17624191
2023-12-17 15:12

满意答案

为了增加aku的优秀答案,对于说英语的人,可以在http://www.hex-rays.com/上找到IDA Pro。


To add to aku's excellent answer, for English speakers, IDA Pro is available at http://www.hex-rays.com/.

相关问答

更多

VC ++的开头[关闭](Beginnings of VC++ [closed])

您需要做的是创建一个基于选择MFC->对话框的应用程序,它将帮助您开始创建对话框和控件,如按钮,单选按钮和复选框。 此外,我建议你阅读这本书。 What you need to do is create a Choose MFC->Dialog based application which will help you to start with creating dialog box and controls like buttons, radio buttons and checkboxes....

使用:: InterlockedIncrement(VC ++)的唯一ID(Unique ID with ::InterlockedIncrement (VC++))

是的,这是合法的 - 包含的访问权限 读,然后 那么增量 写,然后 将递增的值返回给调用者 将是原子的。 只是不要忘记它是32位并且可以溢出。 Yes, that is legal - the access which consists of read, then increment, then write, then return the incremented value to the caller will be atomic. Just don't forget that it's 32 ...

这些天使用VC ++?(Uses of VC++ these days?)

电脑游戏大部分仍然使用Visual Studio在Windows上用C ++编写。 企业应用程序通常使用c#或java,因为企业有更多的钱购买硬件来弥补游戏需要在大量设备上运行的性能差异,例如PS3,Xbox 360,PS3,Windows,Mac等。对内存有限制。 此外,嵌入式产品,系统实用程序和广泛使用多种低级API的软件仍以C ++编写。 它绝对还有用处。 Computer games are mostly still written in C++ on Windows using Visu...

将VC 6.0应用程序移植到VS 2003 VC ++应用程序(Porting VC 6.0 Application to VS 2003 VC++ application)

不,没有要求将.NET与VS 2003(或VS 2008或VS 2010)一起使用。 您可以将VC 6.0项目转移到VS 2003,它仍然是本机项目。 No, there is no requirement to use .NET with VS 2003 (or VS 2008 or VS 2010). You can bring your VC 6.0 project over to VS 2003 and it will still be a native project.

如何在VC ++中获取WPF应用程序的屏幕截图?(How to get screenshot of WPF application in VC++?)

GetDC和BitBlt会改变GDI +场景的任何内容吗? Would GetDC & BitBlt change anything for the GDI+ scenario??

使用CPPUNIT或GTEST对VC ++ MFC应用程序进行单元测试(Unit testing VC++ MFC application using CPPUNIT or GTEST)

我真的不清楚是什么阻止你在没有一些例子的情况下进行测试(也许你可以发明一个简单的例子来证明你的问题)。 如果要访问受保护的类构造函数,可以执行类似这样的操作。 class A { protected: A() {} friend class TestClassA; }; class TestClassA { public: void TestA( void) { A a; // test a } }; ...

如何反汇编VC ++应用程序?(How do I disassemble a VC++ application?)

为了增加aku的优秀答案,对于说英语的人,可以在http://www.hex-rays.com/上找到IDA Pro。 To add to aku's excellent answer, for English speakers, IDA Pro is available at http://www.hex-rays.com/.

.NET VC ++ Redist依赖(.NET VC++ Redist dependency)

检查Environment.Is64BitProcess并相应地加载正确的dll 安装正确的vcredist仍然是一个悬而未决的问题 check Environment.Is64BitProcess and load the right dll accordingly the installation of the right vcredist is still an open problem

如何在Metro应用程序中写入控制台/登录VC ++?(How to write to console/log in VC++ in a Metro app?)

地铁风格的应用程序不能有控制台。 您可以在C ++ / CXX应用程序中使用OutputDebugString()在Visual Studio输出窗口中显示调试文本,就像System.Diagnostics.Debug.Write在托管应用程序中一样。 没有很多批准的winapi函数,但OutputDebugString()没问题。 启动MSDN页面就在这里 。 A metro style app cannot have a console. You can use OutputDebugStri...

相关文章

更多

Hadoop mapred-queue-acls 配置

Hadoop作业提交时可以指定相应的队列,例如:-Dmapred.job.queue.name=que ...

java 监听redis过期key事件实现延迟队列功能

java 监听redis过期key事件,可以实现简单的延迟队列功能。实现起来也特别简单,方法如下:一、 ...

Java 异常处理

Java 异常处理 异常是程序中的一些错误,但并不是所有的错误都是异常,并且错误有时候是可以避免 ...

RabbitMQ 简单队列

生产者将消息发送到队列,消费者从队列中获取消息。 P:消息的生产者 C:消息的消费者 ...

java顺序循环队列最多能容纳60个元素,当front=47,rear=23时,求队列元素个数?

我从网上看到一种做法是用|rear-front+MAX|%MAX,结果是24,那么我想问了这个与直接用 ...

RabbitMQ Work模式消息队列

一个生产者、多个消费者。 一个消息只能被一个消费者获取。 生产者发布消息 private ...

Java企业级应用软件开发

一、什么是软件开发? 计算机系统开发:包括硬件开发和软件开发。 软件开发可以分为系统级开发和应用级 ...

Java Bug模式详解

Java Bug模式详解的内容摘要:英文版:Bug Patterns In Java内容简介本书特点● ...

广州Java培训疯狂Java基础强化营视频教程

视频介绍 本课程以最新的Java7为标准,重点讲解Java核心技术,如集合框架、泛型、IO、NIO、A ...

Open Source Search Engines in Java

Open Source Search Engines in Java Open Source Sear ...

最新问答

更多

您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)

将diff文件复制到存储库的根目录,然后执行以下操作: git apply yourcoworkers.diff 有关apply命令的更多信息, apply 见其手册页 。 顺便说一下:一个更好的方法是通过文件交换整个提交文件是发送者上的命令git format-patch ,然后在接收器上加上git am ,因为它也传送作者信息和提交信息。 如果修补程序应用程序失败,并且生成diff的提交实际上在您的备份中,则可以使用尝试在更改中合并的apply程序的-3选项。 它还适用于Unix管道,如下

将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)

尝试将第二行更改为snprintf(buf1, sizeof buf1, "%.2f", balance1); 。 另外,为什么要声明用该特定表达式分配缓冲区的存储量? EDIT @LưuVĩnhPhúc在下面的评论中提到我的原始答案中的格式说明符将舍入而不是截断,因此根据如何在不使用C舍入的情况下截断小数,您可以执行以下操作: float balance = 200.56866; int tmp = balance1 * 100; float balance1 = tmp / 100.0; c

OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)

这是简单的解决方案 在你需要写的控制器中 BackendMenu::setContext('Archetypics.Team', 'website', 'team'); 请参阅https://octobercms.com/docs/backend/controllers-views-ajax#navigation-context BackendMenu::setContext('Author.Plugin name', 'Menu code', 'Sub menu code'); 你需要在r

页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)

每当发出请求时ASP都会创建一个新的Page对象,并且一旦它将响应发送回用户就不会保留对该Page对象的引用,因此只要你找不到某种方法来保持生命自己引用该Page对象后,一旦发送响应, Page和只能通过该页面访问的所有对象才有资格进行垃圾回收。 ASP creates a new Page object whenever a request is made, and it does not hold onto the reference to that Page object once it

codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)

要在生产服务器中调试这个,你可以临时放 error_reporting(E_ALL); 并查看有哪些其他错误阻止正确的重定向。 您还应该检查生产服务器发送的响应标头。 它是否具有“缓存”,是否需要重新验证标头等 to debug this in production server, you can temporary put error_reporting(E_ALL); and see what other errors are there that prevents the proper

在计算机拍照在哪里进入

打开娥的电脑.在下面找到视频设备点击进去就可以了...

使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)

你是对的。 第一次输入后,换行符将保留在输入缓冲区中。 第一次读取后尝试插入: cin.ignore(); // to ignore the newline character 或者更好的是: //discards all input in the standard input stream up to and including the first newline. cin.ignore(numeric_limits::max(), '\n'); 您必须为#inc

No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)

for (int k = 0; k > 10; k++) { System.out.println(k); } k不大于10,所以循环将永远不会执行。 我想要什么是k<10 ,不是吗? for (int k = 0; k < 10; k++) { System.out.println(k); } for (int k = 0; k > 10; k++) { System.out.println(k); } k is not greater than 10, so loop

单页应用程序:页面重新加载(Single Page Application: page reload)

优点是不注销会避免惹恼用户,以至于他们会想要杀死你:-)。 说真的,如果每次刷新页面时应用程序都会将我注销(或者在新选项卡中打开一个链接),我再也不会使用该应用程序了。 好吧,不要这样做。 确保身份验证令牌存储在刷新后的某个位置,即不在某些JS变量中,而是存储在cookie或本地存储中。 The advantage is that not logging off will avoid pissing off your users so much that they'll want to kill

在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)

EXECUTE IMMEDIATE 'SELECT '||field_val_temp ||' FROM tableb WHERE function_id = :func_val AND rec_key = :rec_key' INTO field_val USING 'STDCUSAC' , yu.rec_key; 和, EXECUTE IMMEDIATE 'UPDATE tablec SET field_val_'||i||' = :field_val' USI