web123456

Read and write lock, why use read and write lock;

  • Running results
  • 2Write operation start:2
  • 2The write operation ends:2
  • 1Write operation start:1
  • 1The write operation ends:1
  • 3Write operation start:3
  • 3The write operation ends:3
  • 4Write operation start:4
  • 4The write operation ends:4
  • 5Write operation start:5
  • 5The write operation ends:5
  • Thread-0Read operation starts:1
  • Thread-2Read operation starts:3
  • Thread-4Read operation starts:5
  • Thread-3Read operation starts:4
  • Thread-1Read operation starts:2
  • Thread-5Read operation starts:6
  • Thread-6Read operation starts:7
  • Thread-7Read operation starts:8
  • Thread-8Read operation starts:9
  • Thread-10Read operation starts:11
  • Thread-9Read operation starts:10
  • Thread-11Read operation starts:12
  • Thread-12Read operation starts:13
  • Thread-13Read operation starts:14
  • Thread-14Read operation starts:15
  • Thread-15Read operation starts:16
  • Thread-16Read operation starts:17
  • Thread-17Read operation starts:18
  • Thread-18Read operation starts:19
  • Thread-19Read operation starts:20
  • Thread-0The read operation endskey : 1resutl: 1
  • Thread-17The read operation endskey : 18resutl: null
  • Thread-13The read operation endskey : 14resutl: null
  • Thread-2The read operation endskey : 3resutl: 3
  • Thread-16The read operation endskey : 17resutl: null
  • Thread-9The read operation endskey : 10resutl: null
  • Thread-19The read operation endskey : 20resutl: null
  • Thread-18The read operation endskey : 19resutl: null
  • Thread-15The read operation endskey : 16resutl: null
  • Thread-14The read operation endskey : 15resutl: null
  • Thread-4The read operation endskey : 5resutl: 5
  • Thread-5The read operation endskey : 6resutl: null
  • Thread-6The read operation endskey : 7resutl: null
  • Thread-10The read operation endskey : 11resutl: null
  • Thread-11The read operation endskey : 12resutl: null
  • Thread-3The read operation endskey : 4resutl: 4
  • Thread-1The read operation endskey : 2resutl: 2
  • Thread-12The read operation endskey : 13resutl: null
  • Thread-7The read operation endskey : 8resutl: null
  • Thread-8The read operation endskey : 9resutl: null