首页 \ 问答 \ 比较两个ip子网(Compare two ip subnet)

比较两个ip子网(Compare two ip subnet)

如何判断两个ip是否在同一个子网上? 唯一的输入是IP地址和子网掩码! 使用C / C ++计算两个ip是否具有相同子网的最佳方法是什么?


How to decide if two ip are on the same subnet or not? The only input is the ip address and the subnet mask! What is the optimal way, using C/C++, to compute if two ip have the same subnet?


原文:https://stackoverflow.com/questions/41432327
更新时间:2024-03-19 20:03

最满意答案

这在Javadocs for Thread很容易找到:

对于currentThread()

返回对当前正在执行的线程对象的引用。

sleep()

导致当前正在执行的线程休眠

即调用两种方法的方法的Thread


That's easily found in the Javadocs for Thread:

For currentThread():

Returns a reference to the currently executing thread object.

For sleep():

Causes the currently executing thread to sleep

I.e. the Thread that calls the method for both methods.

相关问答

更多
  • 只有一种方法,而不是两种,它是静态的。 虽然您可以通过实例引用调用静态方法,但它不是很好的风格。 这表明程序员认为他或她正在调用一个实例方法。 一个困惑的程序员可能会认为他或她可能会导致另一个线程(而不是当前的线程)以这种方式睡觉,这不是它所做的。 你的代码行都是一样的,但第二个是更好的风格。 There is only one method, not two, and it is static. While you can call a static method via an instance refe ...
  • 当消费者拿到最后一个ladoo时,是什么阻止你的制作人完全填充牌并在消费者设法调用wait() 之前调用最后一个notify() wait() ? 同样,当盘子变满时,是什么阻止消费者在生产者进入wait()之前拿最后一个ladoo并调用最后一个notify() wait() ? 如果某个其他线程没有等待接收通知,则对o.notify()调用不会执行任何操作 。 也就是说,对象o不记得它已被通知。 When the consumer takes the last ladoo, what prevents y ...
  • 这在Javadocs for Thread很容易找到: 对于currentThread() : 返回对当前正在执行的线程对象的引用。 sleep() : 导致当前正在执行的线程休眠 即调用两种方法的方法的Thread 。 That's easily found in the Javadocs for Thread: For currentThread(): Returns a reference to the currently executing thread object. For sleep(): C ...
  • Java 8并行流可以(通常!)和手动多线程一样好,但它也取决于具体情况。 你得到RejectedExecutionException是因为你太早关闭了池:你应该在for循环之外调用pool.shutdown() Java 8并行流的一大优势是您不必担心这些问题。 Java 8 parallel streams can be (in general!) as good as manual multithreading, but it also depends on the concrete situatio ...
  • 当你调用makeOrder(); 在餐厅线程中它将等待()。 然后什么都不会发生。 问题是,你只有一个线程,这个线程无法通知自己。 我想你想要做的就是把你的客户,服务员和厨师变成线程。 然后一个接一个地启动它们,然后服务员必须等到客户下订单,厨师必须等到服务员得到订单...... 如果你谷歌搜索“java producer consumer example”,你可能会发现一些有用的例子。 When you call makeOrder(); in the Restaurant thread it will ...
  • 它使用每个HTTP连接一个线程(这不完全是当服务器使用NIO时,但你明白了)。 您的浏览器显然在两个选项卡中使用相同的HTTP连接。 产生两个不同的浏览器实例(例如Firefox和Chrome),你会发现它的工作方式与你的预期一致。 It's using one thread per HTTP connection (it's not exactly that when the server uses NIO, but you got the point). Your browser is apparent ...
  • 那么, Thread.Sleep将线程阻塞一段特定的时间,而Thread.Join阻塞它,直到目标线程终止。 考虑到Thread.CurrentThread在挂起时不会被终止(即使它在外部终止,因为它已经死了没有区别),最终的结果将是相同的。 然而,使用Join会让人困惑,而Sleep很明显。 决定使用哪一个不是比赛。 Well, Thread.Sleep blocks the thread for a specific amount of time while Thread.Join blocks it ...
  • 是的,将您的任务提交给ExecutorService并检查返回的Future的结果。 使用时: ExecutorService es = Executors.newFixedThreadPool(1); Future result = es.submit(new Runnable() { @Override public void run() { throw new Error("sample error"); } }); try { result. ...
  • 由于所有Runnable都是睡眠,因此检查中断本身是不必要的。 但正如你从评论中可以看出的那样,这是一个更大的惯例的模型。 当sleep和wait抛出InterruptedException时,阻塞I / O调用(在注释中列出)不会,并且不等待或休眠的CPU密集型代码也不会。 Bruce E在这里做的是为你提供一个模板,它可以处理抛出InterruptedException的情况(他用它来退出循环),还处理没有睡眠或等待的情况,并且没有InterruptedException抛出。 它让读者知道他们可以选择 ...
  • 为什么私有Thread currentThread = Thread.currentThread(); 不是指当前的线程? 因为在这个变量初始化时,你在主线程上。 (当您执行ExtendsThread extendsThread = new ExtendsThread();时,该变量被初始化ExtendsThread extendsThread = new ExtendsThread();并且这是从main完成的。) 但是,代码还存在其他问题。 你正在检查currentThread上的中断而不是this线程 ...

相关文章

更多

最新问答

更多
  • 您如何使用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?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)