Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Synchronize the main method
03-29-2008, 03:48 PM
Post: #1
Synchronize the main method
Can we sychronize the main method?
Find all posts by this user
Quote this message in a reply
03-29-2008, 03:55 PM
Post: #2
RE: Synchronize the main method
What is the use of making the main method synzhronized. main is the entry point for the application and I think only one thread will be accessing this method
Find all posts by this user
Quote this message in a reply
03-29-2008, 03:58 PM
Post: #3
RE: Synchronize the main method
Yeah. We don't need to synchronize the main method. But even if you add the synchronized modifier to the main method it would work.

[java]
public class Main {
public synchronized static void main(String args[]){
System.out.println("main method...");
}

}
[/java]
Visit this user's website Find all posts by this user
Quote this message in a reply
09-21-2009, 03:36 PM (This post was last modified: 09-21-2009 03:37 PM by kumarmanish.nitc.)
Post: #4
RE: Synchronize the main method
(03-29-2008 03:58 PM)albinjoseph Wrote:  Yeah. We don't need to synchronize the main method. But even if you add the synchronized modifier to the main method it would work.

[java]
public class Main {
public synchronized static void main(String args[]){
System.out.println("main method...");
}

}
[/java]

why don't need to synchronize the main method.
why don't we need to synchronize the main method.
Find all posts by this user
Quote this message in a reply
09-22-2009, 02:54 PM
Post: #5
RE: Synchronize the main method
(09-21-2009 03:36 PM)kumarmanish.nitc Wrote:  
(03-29-2008 03:58 PM)albinjoseph Wrote:  Yeah. We don't need to synchronize the main method. But even if you add the synchronized modifier to the main method it would work.

[java]
public class Main {
public synchronized static void main(String args[]){
System.out.println("main method...");
}

}
[/java]

why don't need to synchronize the main method.
why don't we need to synchronize the main method.

http://www.javacodez.com/forums/synchron...html#pid55
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: