Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: synchronisation of code in multiple instance of jvm

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Lightbulb synchronisation of code in multiple instance of jvm

    hi all

    There is method in the class of my application and there are four other class which is running in different machine means different jvm and these classes are accessing the method of my class. then how to protect my method from accessing other class at the same time.

    i am not able to use synchronized keyword because this works only for single jvm.
    so pls provide me some solution for this.

    pls provide me solution for this.
    Last edited by srkmca07@gmail.com; May 27th, 2014 at 03:54 AM.


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,520
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: synchronisation of code in multiple instance of jvm

    Please provide a short, runnable example that demonstrates the problem.

  3. #3
    Senior Member
    Join Date
    Jul 2013
    Location
    Europe
    Posts
    666
    Thanks
    0
    Thanked 121 Times in 105 Posts

    Default Re: synchronisation of code in multiple instance of jvm

    Might be, that I did not understand your question correctly, but I think you want to prevent the user from starting the same java application twice, correct?
    If this is the case then unfortunately, you cant do this in a clean way.
    A litte hack that you can use is to create a socket on a specific port, when this port is already in use then you can assume, that your application is already running. (or some other application which uses the same port) Its not nice and I wouldnt recommend it, but it gets the job done.

Similar Threads

  1. Thread synchronisation help!
    By bassie in forum What's Wrong With My Code?
    Replies: 14
    Last Post: December 24th, 2012, 10:56 AM
  2. Using the same scanner multiple times in code help
    By theostorm in forum What's Wrong With My Code?
    Replies: 3
    Last Post: September 16th, 2012, 11:30 PM
  3. Help with Synchronisation with a semaphore
    By Stockholm Syndrome in forum Threads
    Replies: 5
    Last Post: March 8th, 2012, 09:36 PM
  4. Multiple nullpointerexceptions in my code.
    By javastudnt in forum What's Wrong With My Code?
    Replies: 7
    Last Post: November 2nd, 2011, 11:30 PM
  5. does anyone know assembly code for JVM?
    By javapenguin in forum Other Programming Languages
    Replies: 2
    Last Post: April 6th, 2011, 02:16 AM

Tags for this Thread