Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8203083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T07:25:19+00:00 2026-06-07T07:25:19+00:00

I have a project which requires logging in my router from time to time

  • 0

I have a project which requires logging in my router from time to time and make some changes. In eclipse I have a separate project which deals with all the things I need changed and I have that in the build path of my main project which is a multi threaded project. My problem is that sometimes two threads try to access the router which messes things up. Is there anything I can do that only one thread can access a certan part of my code.

This is the related code for the main multithreaded application

if (totalLogins > 10)
{
  IpManager.rebootRouter();
  Thread.sleep(4000);
  totalLogins = 0;
  composedMessagesWithThisIP = 0;
}

And in the other project this is what I have

public synchronized static void rebootRouter()
{
  try
  {
    //code related to restart modem
  }
  catch (Exception e)
  {

  }
}

So what I have done is made the method synchronized but I believe from time to time more than one thread access the “rebootRouter” method. Which causes problems in my main application.

What is the best way and most effective way to make IpManager.rebootRouter() be executed by one thread only?

Regards!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T07:25:22+00:00Added an answer on June 7, 2026 at 7:25 am

    synchronized guarantees that only one thread can enter the block at a time, but AFAIR the same thread can enter the block multiple times (so threads don’t deadlock against themselves), and if a thread is blocked because another thread is in there then it may run immediately after the first thread leaves the synchronized block.

    First I’d throw logging at the entry and exit points of the routine.
    I’d check to see that you don’t have any recursion going on, and make sure that the calls really are running at the same time. Also, remember if there’s any asynchronous work or callbacks the synchronized block may be exited.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have taken on a project from a client which requires me to set
I have a .NET 4.0 ASP.NET project which requires some threading work I've never
I have started working on a project which requires Natural Language Processing. We have
I have a project which builds correctly from the command line. On one of
I have a project which requires me to setup an subscription-based online learning site
I have a project which requires printing an HTML table with many rows. My
I am working on a project which requires some pretty intricate JavaScript processing. This
I have a setup project which, as a prerequisite, requires the .Net 4 framework
I have a project for a class which requires that if a database is
I have a class on low-level programming which requires a final project (syllabus at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.