| |

VerySource

 Forgot password?
 Register
Search
View: 525|Reply: 2

Is there any difference in the writing of these two examples in operation?

[Copy link]

2

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-3-22 15:00:02
| Show all posts |Read mode
Example2_2.jsp:
<% @ page contentType = "text / html; charset = GB2312"%>
<HTML>
<BODY BGCOLOR = cyan> <FONT size = 1>
  <%! int i = 0;
  %>
  <% i ++;
  %>
<P> You are the first
   <% = i%>
  Customers who visited this site.
</ BODY>
</ HTML>

===============================
(2) Example 3
Example2_3.jsp:
<% @ page contentType = "text / html; charset = GB2312"%>
<HTML>
<BODY>
  <%! Integer number = new Integer (0);
  %>
   <%
      synchronized (number)
      {int i = number.intValue ();
        i ++;
        number = new Integer (i);
  }
%>
<P> You are the first
   <% = number.intValue ()%>
Customers who visited this site.
</ BODY>
</ HTML>
Reply

Use magic Report

0

Threads

11

Posts

9.00

Credits

Newbie

Rank: 1

Credits
9.00

 Korea, Republic of

Post time: 2020-6-30 15:45:02
| Show all posts
There is no difference, i++ does not need to synchronize, it is an atomic operation itself
Reply

Use magic Report

2

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 Japan

 Author| Post time: 2020-6-30 17:15:01
| Show all posts
Oh, thanks....
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list